當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。