当前位置: 首页>>代码示例>>PHP>>正文


PHP validator::make方法代码示例

本文整理汇总了PHP中validator::make方法的典型用法代码示例。如果您正苦于以下问题:PHP validator::make方法的具体用法?PHP validator::make怎么用?PHP validator::make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator的用法示例。


在下文中一共展示了validator::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postSetInitial

 public function postSetInitial(Request $request)
 {
     $session_id = $request->input('session_id');
     $input = ['session_id' => $session_id];
     $validator = validator::make($request->all(), ['session_id' => 'required']);
     if ($validator->fails()) {
         return ApiResponseClass::errorResponse('You Have Some Input Errors. Please Try Again!!', $input, $validator->errors());
     } else {
         $user_registered_to_school = UsersRegisteredToSchool::where('user_id', Auth::user()->id)->get()->first();
         if ($user_registered_to_school) {
             $user_registered_to_session = UsersRegisteredToSession::where('session_id', $session_id)->where('user_id', Auth::user()->id)->get()->first();
             if ($user_registered_to_session) {
                 return ApiResponseClass::successResponse($user_registered_to_session, $input);
             }
             $user_registered_to_session = new UsersRegisteredToSession();
             $user_registered_to_session->session_id = $session_id;
             $user_registered_to_session->school_id = $user_registered_to_school->school_id;
             $user_registered_to_session->user_id = Auth::user()->id;
             $user_registered_to_session->save();
             if ($user_registered_to_session->save()) {
                 return ApiResponseClass::successResponse($user_registered_to_session, $input);
             }
         }
     }
     return ApiResponseClass::errorResponse('There is Something Wrong. Please Try Again!!', $input);
 }
开发者ID:summmmit,项目名称:web,代码行数:26,代码来源:TeacherAccountController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user_id = Auth::User()->id;
     if (Input::file()) {
         $file_image = array('image' => Input::file('file_image'));
         $rules = array('image' => 'required');
         $validator = validator::make($file_image, $rules);
         if ($validator->fails()) {
             return redirect::to('photo')->withInput()->withErrors($validator);
         } else {
             if (Input::file('file_image')->isValid()) {
                 $path = '../public/images';
                 $extension = Input::file('file_image')->getClientOriginalExtension();
                 $fileName = rand() . '.' . $extension;
                 Input::file('file_image')->move($path, $fileName);
                 Image::create(array('user_id' => $user_id, 'path' => $fileName));
                 Session::flash('success', 'Upload successfully');
                 return Redirect::to('photo');
             } else {
                 Session::flash('error', 'uploaded file is not valid');
                 return Redirect::to('photo');
             }
         }
     }
 }
开发者ID:GrigorAtaryan,项目名称:Social_network,代码行数:31,代码来源:ImageController.php

示例3: __checkdata

 private function __checkdata($contentData)
 {
     $nodeMdl = app::get('sysinfo')->model('article_nodes');
     $validator = validator::make(['title' => $contentData['title'], 'node_id' => $contentData['node_id']], ['title' => 'required', 'node_id' => 'required'], ['title' => '资讯标题不能为空', 'node_id' => '资讯节点id不能为空']);
     if ($validator->fails()) {
         $messages = $validator->messagesInfo();
         foreach ($messages as $error) {
             throw new LogicException($error[0]);
         }
     }
     $nodeInfo = $nodeMdl->getRow('parent_id', array('node_id' => $contentData['node_id']));
     if ($nodeInfo['parent_id'] == 0) {
         throw new \LogicException('请选择二级分类!');
     }
     $data['node']['node_id'] = $contentData['node_id'];
     $data['article']['content'] = $contentData['content'];
     $data['article']['node_id'] = $contentData['node_id'];
     $data['article']['title'] = $contentData['title'];
     $data['article']['platform'] = $contentData['platform'];
     $data['article']['article_logo'] = $contentData['article_logo'];
     $data['article']['modified'] = time();
     $data['article']['platform'] = $contentData['platform'];
     if ($contentData['article_id']) {
         $data['article']['article_id'] = $contentData['article_id'];
     }
     return $data;
 }
开发者ID:453111208,项目名称:bbc,代码行数:27,代码来源:article.php

示例4: save

 public function save()
 {
     $post = input::get();
     $ruledata = $post['ruledata'];
     $H = $post['_DTIME_']['H'];
     $M = $post['_DTIME_']['M'];
     foreach ($H as $key => $val) {
         $ruledata[$key] = strtotime($post[$key] . " " . $val . ":" . $M[$key]);
     }
     $validator = validator::make(array('0' => $ruledata['buy_limit'], '1' => $ruledata['discount_min'], '2' => $ruledata['discount_max'], '3' => date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '4' => date('Y-m-d H:i:s', $ruledata['apply_end_time']), '5' => date('Y-m-d H:i:s', $ruledata['release_time']), '6' => date('Y-m-d H:i:s', $ruledata['start_time']), '7' => date('Y-m-d H:i:s', $ruledata['end_time']), '8' => $ruledata['shoptype'], '9' => $ruledata['limit_cat'], '10' => $ruledata['activity_name'], '11' => $ruledata['activity_tag']), array('0' => 'min:0', '1' => 'numeric|min:0.01|max:99.99', '2' => 'numeric|max:99.99|min:' . $ruledata['discount_min'], '3' => 'after:' . date('Y-m-d H:i:s', time()), '4' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '5' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_end_time']), '6' => 'after:' . date('Y-m-d H:i:s', $ruledata['release_time']), '7' => 'after:' . date('Y-m-d H:i:s', $ruledata['start_time']), '8' => 'required', '9' => 'required', '10' => 'required|max:20', '11' => 'required|max:10'), array('0' => '用户限购数量要大于0!', '1' => '折扣必须是数字|折扣范围必须大于0|折扣范围必须小于100', '2' => '折扣必须是数字|折扣范围必须小于100|折扣范围必须由小到大!', '3' => '活动报名的开始时间必须大于当前时间!', '4' => '活动报名结束时间必须大于报名的开始时间!', '5' => '发布时间必须大于报名结束时间!', '6' => '活动生效时间必须大于活动发布时间!', '7' => '活动生效结束时间必须大于活动开始时间!', '8' => '至少选择一种店铺类型!', '9' => '至少选择一种平台商品类目!', '10' => '|活动名称长度必须小于20', '11' => '|活动标签长度必须小于10'));
     if ($validator->fails()) {
         $messages = $validator->messagesInfo();
         foreach ($messages as $error) {
             return $this->splash('error', null, $error[0]);
         }
     }
     $this->begin("?app=syspromotion&ctl=admin_activity&act=index");
     try {
         kernel::single('syspromotion_activity')->saveActivity($ruledata);
         $this->adminlog("添加活动{$post['activity_name']}", 1);
     } catch (Exception $e) {
         $this->adminlog("添加活动{$post['activity_name']}", 0);
         $msg = $e->getMessage();
         $this->end(false, $msg);
     }
     $this->end(true);
 }
开发者ID:453111208,项目名称:bbc,代码行数:27,代码来源:activity.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $url = $request->input('url');
     //验证提交的url
     $target = ['url' => $url];
     $roule = ['url' => 'required|url'];
     $message = ['url' => $url . '不是合法的url', 'required' => '请求输入url'];
     $validator = validator::make($target, $roule, $message);
     if ($validator->fails()) {
         return redirect('url')->withErrors($validator);
     }
     //检测在数据库
     $result = Url::where('url', $url)->first();
     //dd($result);
     if ($result) {
         return view('url.result')->with('short_url', $result->short_url);
     }
     //检测不在数据库
     $short_url = Url::get_short_url();
     $res = Url::insert(['url' => $url, 'short_url' => $short_url]);
     if ($res) {
         return view('url.result')->with('short_url', $short_url);
     } else {
         return '数据添加失败';
     }
 }
开发者ID:jew977,项目名称:laravel5_unique_short_url-,代码行数:31,代码来源:UrlController.php

示例6: TambahJadwal

 public function TambahJadwal()
 {
     $rules = array('unit_id' => 'required', 'kategori' => 'required', 'tglstart' => 'required', 'tglases' => 'required', 'tglfinish' => 'required', 'detail' => 'required');
     $messages = array('unit_id.required' => 'Nama Jabatan Harus Terisi', 'kategori.required' => 'Kategori Harus Dipilih', 'tglstart.required' => 'Tanggal Mulai Harus Terisi', 'tglases.required' => 'Tanggal Asessment Harus Terisi', 'tglfinish.required' => 'Tanggal Selesai Harus Terisi', 'detail.required' => 'Detail Harus terisi');
     $validasi = validator::make(Input::all(), $rules, $messages);
     if ($validasi->fails()) {
         return Redirect::back()->withErrors($validasi)->withInput();
     } else {
         $kat = Input::get('kategori');
         if ($kat == 'internal') {
             $aa = "in";
         } else {
             $aa = "ex";
         }
         DB::transaction(function ($aa) use($aa) {
             //asesment promosi
             $jadwal = KandidatPromote::create(['unit_staf_id' => Input::get('unit_id'), 'tgl_awal' => Input::get('tglstart'), 'tgl_asesment' => Input::get('tglases'), 'tgl_selesai' => Input::get('tglfinish'), 'detail' => Input::get('detail')]);
             //rekrutmen rekap header
             $rekap_header = HeaderRekap::create(['id_asesmen' => $jadwal->id, 'kategori' => Input::get('kategori'), 'nama' => Input::get('jabatan'), 'tanggal_awal' => Input::get('tglstart'), 'tanggal_akhir' => Input::get('tglfinish'), 'deksripsi' => Input::get('detail')]);
             //asessment promosi daftar
             $daftar = KandidatPromosiDaftar::create(['asesment_promosi_id' => $jadwal->id, 'nip' => Input::get('nip'), 'detail' => Input::get('detail')]);
             //rekrutment rekap profiling
             $profil = ProfilingRekap::create(['id_rekap' => $rekap_header->id, 'kategori' => $aa, 'nip' => $daftar->nip, 'id_jabatan' => $jadwal->unit_staf_id]);
         });
         Session::flash('message', 'Berhasil Menambahkan Jadwal Asessment');
         return Redirect::to('career/jadwal/lihat/asessment');
     }
 }
开发者ID:hendrilara,项目名称:kemenpan,代码行数:28,代码来源:KandidatPromosiController.php

示例7: signin

 public function signin(Request $request)
 {
     $input = $request->all();
     $validator = validator::make($input, ['username' => 'required|exists:user', 'password' => 'required']);
     if (Auth::attempt(['username' => $input['username'], 'password' => $input['password'], 'activated' => 1])) {
         return redirect(route('default.home'));
     } else {
         return redirect()->back()->withErrors('Invalid Credentials or user not active.');
     }
 }
开发者ID:jkevinp,项目名称:bepco,代码行数:10,代码来源:AuthController.php

示例8: __checkQuantity

 private function __checkQuantity($quantity)
 {
     $quantityValidate = ['bn' => 'required|max:30', 'quantity' => 'required|numeric'];
     $validator = validator::make($quantity, $quantityValidate);
     if ($validator->fails()) {
         $errors = json_decode($validator->messages(), 1);
         foreach ($errors as $error) {
             throw new LogicException($error[0]);
         }
     }
 }
开发者ID:453111208,项目名称:bbc,代码行数:11,代码来源:updateStore.php

示例9: saving

 function saving($model)
 {
     if (!is_null($model->published_at)) {
         $rules['published_at'] = ['date'];
         $validator = validator::make($model->toArray(), $rules);
         if ($validator->fails()) {
             $model->setErrors($validator->messages());
             return false;
         }
     }
 }
开发者ID:ThunderID,项目名称:Halo,代码行数:11,代码来源:HasPublishedAtObserver.php

示例10: __checkdata

 private function __checkdata($data)
 {
     $validator = validator::make(['shop_id' => $data['shop_id'], 'item_id' => $data['item_id'], 'sku_id' => $data['sku_id'], 'email' => $data['email']], ['shop_id' => 'required', 'item_id' => 'required', 'sku_id' => 'required', 'email' => 'required|email'], ['shop_id' => '店铺id不能为空!', 'item_id' => '商品id不能为空!', 'sku_id' => '货品id不能为空!', 'email' => '邮件不能为空!|邮件格式不正确!']);
     if ($validator->fails()) {
         $messages = $validator->messagesInfo();
         foreach ($messages as $error) {
             throw new LogicException($error[0]);
         }
     }
     return $data;
 }
开发者ID:453111208,项目名称:bbc,代码行数:11,代码来源:memberItem.php

示例11: postCreate

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function postCreate()
 {
     //
     $validator = validator::make(Input::all(), Category::$rules);
     if ($validator->passes()) {
         $category = new Category();
         $category->name = Input::get('name');
         $category->save();
         return Redirect::to('admin/categories/index')->with('message', 'Category Created');
     }
     return Redirect::to('admin/categories/index')->with('message', 'Something went wrong')->withErrors($validator)->withInput();
 }
开发者ID:jestintab,项目名称:umt,代码行数:17,代码来源:CategoryController.php

示例12: postCreate

 public function postCreate(Request $request)
 {
     $email = $request->input('email');
     $password = $request->input('password');
     $password_again = $request->input('password_again');
     $inputs = ['email' => $email, 'password' => $password, 'password_again' => $password_again];
     $validator = validator::make($request->all(), ['email' => 'required|unique:users|email', 'password' => 'required|max:16|min:6', 'password_again' => 'required|same:password']);
     if ($validator->fails()) {
         return ApiResponseClass::errorResponse('You Have Some Input Errors', $inputs, $validator->errors());
     }
     $isUrlUser = $request->is('user/*');
     $isUrlAdmin = $request->is('admin/*');
     $isUrlTeacher = $request->is('teacher/*');
     $group_id = null;
     if ($isUrlUser) {
         $group_id = Groups::Student_Group_Id;
     } elseif ($isUrlAdmin) {
         $group_id = Groups::Administrator_Group_ID;
     } elseif ($isUrlTeacher) {
         $group_id = Groups::Teacher_Group_Id_Group_ID;
     }
     DB::beginTransaction();
     try {
         Groups::findorFail($group_id);
         $user = new User();
         $user->email = $email;
         $user->password = Hash::make('password');
         $user->activated = 0;
         $user->email_updated_at = date("Y-m-d h:i:s");
         $user->password_updated_at = date("Y-m-d h:i:s");
         $user->activation_code = str_random(64);
         if (!$user->save()) {
             throw new \ErrorException();
         }
         $user_group = new UsersGroups();
         $user_group->user_id = $user->id;
         $user_group->groups_id = $group_id;
         if (!$user_group->save()) {
             throw new \ErrorException();
         }
         DB::commit();
     } catch (ModelNotFoundException $e) {
         DB::rollback();
         return ApiResponseClass::errorResponse('ModelNotFoundException', $inputs);
     } catch (\ErrorException $e) {
         DB::rollback();
         return ApiResponseClass::errorResponse('ModelNotSavedException', $inputs);
     }
     // Send mail to the user if not the test Shop Id.
     return ApiResponseClass::successResponse($user, $inputs);
 }
开发者ID:summmmit,项目名称:web,代码行数:51,代码来源:UserLoginController.php

示例13: postChat

 public function postChat($partner_id)
 {
     $validator = validator::make(Request::all(), Message::$rules);
     $user = Auth::user();
     $partner = User::find($partner_id);
     if ($validator->passes()) {
         $message = new Message();
         $message->sender_id = $user->id;
         $message->receiver_id = $partner_id;
         $message->content = Request::input('content');
         $message->save();
     }
     $messages = $user->chat($partner_id);
     //return view('messages.chat')->with('messages', $messages)->with('user', $user)->with('partner', $partner);
     return redirect('messages/chat/' . $partner_id);
 }
开发者ID:HenOltma,项目名称:EventMap,代码行数:16,代码来源:MessageController.php

示例14: storeMessage

 public function storeMessage(Request $request, Ngo $ngo)
 {
     $rules = ['sender' => 'required|max:255', 'subject' => 'required|max:255', 'body' => 'required|min:20'];
     $validator = validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/envy/' . $ngo->user_id . '/contact-us')->withErrors($validator);
     } else {
         $message = new Message();
         $message->user_id = $ngo->user_id;
         $message->sender = $request->sender;
         $message->message_subject = $request->subject;
         $message->message_body = $request->body;
         $message->sent_date = (new DateTime())->format('Y-m-d H:i:s');
         $message->save();
         return redirect('/envy/' . $ngo->user_id . '/contact-us');
     }
 }
开发者ID:umarhussain15,项目名称:web_semester_project_integration_repo_Jan16,代码行数:17,代码来源:NgoController.php

示例15: __checkItems

 private function __checkItems($item)
 {
     if (!is_array($item)) {
         throw new LogicException('item参数格式不正确');
     }
     $deliveryDetailValidate = array('oid' => 'required', 'num' => 'required|numeric');
     foreach ($item as $k => $val) {
         $validator = validator::make($val, $deliveryDetailValidate);
         if ($validator->fails()) {
             $errors = json_decode($validator->messages(), 1);
             foreach ($errors as $error) {
                 throw new LogicException($error[0]);
             }
         }
         $newItem[$k]['oid'] = $val['oid'];
         $newItem[$k]['number'] = $val['num'];
     }
     return $newItem;
 }
开发者ID:453111208,项目名称:bbc,代码行数:19,代码来源:tradeDelivery.php


注:本文中的validator::make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。