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


PHP request::has方法代码示例

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


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

示例1: addOffer

 public function addOffer(request $request)
 {
     $rules = array('title' => 'required', 'fineprint' => 'required', 'startDate' => 'required', 'endDate' => 'required');
     $Validator = $this->customValidator($request->all(), $rules, array());
     if ($Validator->fails()) {
         return response()->json(['response_code' => 'ERR_RULES', 'messages' => $Validator->errors()->all()], 400);
     }
     $is_parent = false;
     $offerArr = $request->only('title', 'fineprint');
     $offerArr['startDate'] = date('Y-m-d H:i:s', strtotime($request->input('startDate')));
     $offerArr['endDate'] = date('Y-m-d H:i:s', strtotime($request->input('endDate')));
     if ($request->has('store_token')) {
         if ($request->input('store_token') == 'all' && Auth::user()->Stores->is_parent) {
             $store_id = Auth::user()->Stores->id;
             $is_parent = true;
         } else {
             if ($request->input('store_token') == 'all') {
                 return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
             } else {
                 $storeId = Crypt::decrypt($request->input('store_token'));
                 if (!$this->checkUserHasStorePermission($storeId)) {
                     return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
                 }
                 $store_id = $storeId;
             }
         }
     } else {
         $store_id = Auth::user()->Stores->id;
     }
     $offerArr['store_id'] = $store_id;
     $offer = Offers::create($offerArr);
     if ($is_parent) {
         //creating offer for all sub merchants if user selects and if he is super merchant
         $offer->is_parent = true;
         $offer->save();
         $matchThese = ['is_child' => true, 'parent_id' => $store_id];
         $stores = MerchantStore::where($matchThese)->get();
         $offerInp = $request->only('title', 'fineprint', 'startDate', 'endDate');
         $offerInp['is_child'] = true;
         $offerInp['parent_id'] = $offer->id;
         foreach ($stores as $store) {
             $offerInp['store_id'] = $store->id;
             Offers::create($offerInp);
         }
     }
     return response()->json(['response_code' => 'RES_SOC', 'messages' => 'Store Offer Created', 'data' => $offer], 201);
 }
开发者ID:abhilash698,项目名称:kachingApp,代码行数:47,代码来源:MerchantServiceV2.php

示例2: unpaid_report

 public function unpaid_report($semester_id, request $request)
 {
     $statistics = Student::select('name', 'username', 'email', 'mobile', 'gender', 'national_id')->where('state', 'active')->where('free_percent', 0)->whereNotIn('id', function ($query) {
         $query->select('student_id')->from('financial_invoices')->where('semester_id', 9)->where('type', 'credit');
     })->whereIn('id', function ($query) {
         $query->select('student_id')->from('student_subjects')->where('semester_id', 9)->where('state', 'study')->distinct();
     });
     if ($request->has('name')) {
         $statistics->where('name', 'LIKE', "%" . $request->input('name') . '%');
     }
     if ($request->has('code')) {
         $statistics->where('username', $request->input('code'));
     }
     $statistics = $statistics->orderBy('name', 'ASC')->get();
     /*
     		$statistics = DB::select("
     			SELECT name , username , email, mobile , gender , national_id
     			from students
     			where
     			state = 'active'
     			AND
     			free_percent = 0
     			AND
     			id not IN
     			( SELECT student_id from financial_invoices where semester_id = 9 and type = 'credit')
     			AND
     			id IN
     			( SELECT DISTINCT student_id from student_subjects where semester_id = 9 and state = 'study')
     			");
     */
     return view('financials::reports.unpaid', compact('statistics'));
 }
开发者ID:hisambahaa,项目名称:DARES,代码行数:32,代码来源:FinancialsController.php

示例3: postStore

 public function postStore(request $request)
 {
     $rules = array('store_name' => 'required|min:2|max:60', 'description' => 'required|min:10', 'tags' => 'required', 'cost_two' => 'required', 'landline' => 'required');
     $Validator = $this->customValidator($request->all(), $rules, array());
     if ($Validator->fails()) {
         return response()->json(['response_code' => 'ERR_RULES', 'messages' => $Validator->errors()->all()], 400);
     }
     $storeInput = $request->only('store_name', 'description', 'cost_two', 'landline');
     if ($request->has('veg')) {
         $storeInput['veg'] = $request->input('veg');
     }
     $storeInput['user_id'] = Auth::id();
     $tags = $request->only('tags');
     $tagStore = explode(',', $tags['tags']);
     $store = MerchantStore::create($storeInput);
     if ($request->hasFile('logo')) {
         $image = $request->file('logo');
         $imageName = strtotime(Carbon::now()) . md5($store->id) . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/img/stores/' . $imageName);
         Image::make($image->getRealPath())->resize(280, null, function ($constraint) {
             $constraint->aspectRatio();
         })->save($path);
         $store->logoUrl = $imageName;
     }
     $store->status = true;
     //commet it when required
     $store->save();
     $store->tags()->attach($tagStore);
     return response()->json(['response_code' => 'RES_SC', 'messages' => 'Store Created', 'data' => $store], 201);
 }
开发者ID:abhilash698,项目名称:kachingApp,代码行数:30,代码来源:MerchantService.php

示例4: addOffer

 public function addOffer(request $request)
 {
     $rules = array('title' => 'required', 'fineprint' => 'required', 'startDate' => 'required', 'endDate' => 'required');
     $validator = $this->customValidator($request->all(), $rules, array());
     if ($validator->fails()) {
         return response()->json(['status' => 'fail', 'message' => $validator->errors()->all()]);
     }
     $is_parent = false;
     $fineprintArr = explode("\n", $request->input('fineprint'));
     $fineprint = '';
     foreach ($fineprintArr as $value) {
         if ($value != '' || !empty($value)) {
             $fineprint .= '<li>' . $value . '</li>';
         }
     }
     if ($request->has('store_token')) {
         if ($request->input('store_token') == 'all' && Auth::user()->Stores->is_parent) {
             $store_id = Auth::user()->Stores->id;
             $is_parent = true;
         } else {
             if ($request->input('store_token') == 'all') {
                 return response()->json(['status' => 'fail', 'message' => 'Not Authorized']);
             } else {
                 $storeId = Crypt::decrypt($request->input('store_token'));
                 if (!$this->checkUserHasStorePermission($storeId)) {
                     return response()->json(['status' => 'fail', 'message' => 'Not Authorized']);
                 }
                 $store_id = $storeId;
             }
         }
     } else {
         $store_id = Auth::user()->Stores->id;
     }
     $offerInput = $request->only('title', 'startDate', 'endDate');
     $offerInput['store_id'] = $store_id;
     $offerInput['fineprint'] = $fineprint;
     $offer = Offers::create($offerInput);
     if ($is_parent) {
         $offer->is_parent = true;
         $offer->save();
         //creating offer for all sub merchants if user selects and if he is super merchant
         $matchThese = ['is_child' => true, 'parent_id' => $store_id];
         $stores = MerchantStore::where($matchThese)->get();
         $offerInp = $request->only('title', 'fineprint', 'startDate', 'endDate');
         $offerInp['is_child'] = true;
         $offerInp['parent_id'] = $offer->id;
         foreach ($stores as $store) {
             $offerInp['store_id'] = $store->id;
             Offers::create($offerInp);
         }
     }
     return response()->json(['status' => 'success']);
 }
开发者ID:abhilash698,项目名称:kachingApp,代码行数:53,代码来源:MerchantController.php

示例5: validateForm

 /**
  * Validate the form from the specification provided. The definition data
  * is an associative array having the field name as the key and the
  * definition as the value. The following syntax is used:
  *
  * validate {email|ip|int|bool[ean]|float}  - validate form
  *
  * between MIN and MAX  - valid if field between min and max
  *
  * above VALUE  - valid if field above value
  *
  * below VALUE  - valid if field below value
  *
  * netmask {IP/MASK}[;{IP/MASK}..]  - valid if ip in one of the masks
  *
  * match REGEX  - valid if regex match
  *
  * as OTHERFIELD  - valid if value is same as other field
  *
  * minlength LEN  - valid if longer than len
  *
  * maxlength LEN  - valid if shorter than len
  *
  * @param string $data The field definition data
  * @return bool True if the form is valid
  */
 public function validateForm($data)
 {
     $toks = 'validate:1 between:1 and:1 above:1 below:1 netmask:1 ' . 'match:1 as:1 minlength:1 maxlength:1 required:0 default:1';
     $this->fields = $data;
     $this->valid = true;
     // Go over each of the expected form fields
     foreach ((array) $data as $field => $attr) {
         if (request::has($field)) {
             $this->raw[$field] = (string) request::get($field);
         } else {
             $this->raw[$field] = null;
         }
         $valid = true;
         $data = $this->raw[$field];
         $t = new Tokenizer($toks, $attr);
         $ta = $t->getTokens();
         foreach ($t as $tok => $arg) {
             switch ($tok) {
                 case 'validate':
                     switch ($arg) {
                         case 'email':
                             $valid = filter_var($data, FILTER_VALIDATE_EMAIL);
                             break;
                         case 'ip':
                             $valid = filter_var($data, FILTER_VALIDATE_IP);
                             break;
                         case 'int':
                             $valid = filter_var($data, FILTER_VALIDATE_INT);
                             break;
                         case 'bool':
                         case 'boolean':
                             $valid = filter_var($data, FILTER_VALIDATE_BOOL);
                             break;
                         case 'float':
                             $valid = filter_var($data, FILTER_VALIDATE_FLOAT);
                             break;
                         case 'file':
                             // is a file?
                             break;
                         default:
                             throw new BaseException('Invalid validation type: ' . $arg);
                     }
                     break;
                 case 'between':
                     // check if between $arg and ['and']
                     $min = $arg;
                     if (!isset($ta['and'])) {
                         throw new BaseException('Form field definition using "between" without "and"');
                     }
                     $max = $ta['and'];
                     if ($data < $min || $data > $max) {
                         $valid = false;
                     }
                     break;
                 case 'minlength':
                     if (strlen($data) < $arg) {
                         $valid = false;
                     }
                     break;
                 case 'maxlength':
                     if (strlen($data) > $arg) {
                         $valid = false;
                     }
                     break;
                 case 'above':
                     if ($data < $arg) {
                         $valid = false;
                     }
                     break;
                 case 'below':
                     if ($data > $arg) {
                         $valid = false;
                     }
                     break;
//.........这里部分代码省略.........
开发者ID:noccy80,项目名称:lepton-ng,代码行数:101,代码来源:forms.php

示例6: validate

 /**
  * @todo Document
  * @param array $meta
  * @return type 
  */
 public function validate(array $meta)
 {
     $formdata = $meta['formdata'];
     foreach ($this->_items as $ci) {
         if (is_a($ci, WizardLayoutControl)) {
             $ci->validate($meta);
         } else {
             $key = $ci->getKey();
             $formdata[$key]['changed'] = true;
             // Do the validation here
             if (arr::hasKey($formdata, $key) && request::has($key) && $formdata[$key]['value'] == (string) request::get($key)) {
                 // Not changed, so query previous state of validation
                 $formdata[$key]['changed'] = false;
                 if ($formdata[$key]['valid'] != true) {
                     // Do validation
                 }
             } else {
                 // Insert into array
                 $formdata[$key] = array('value' => (string) request::get($key), 'valid' => $formdata[$key]['valid']);
             }
         }
     }
     return $formdata;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:29,代码来源:wizard.php

示例7: postIndex

 public function postIndex(request $request)
 {
     $this->data['title'] = "Travel applications";
     //if immigration...
     if (Auth::user()->department_id == 6) {
         $this->data['title'] = "Approved travel applications";
         $matchThese = [];
         $travelApplications = travelApplication::where($matchThese)->orderBy('updated_at', 'desc')->get();
         $this->data['travelApplications'] = $travelApplications;
         return view('dashboard', $this->data);
     } else {
         $matchThese = [];
         if ($request->has('province')) {
             $matchThese["province"] = $request->province;
         } else {
             if (Auth::user()->province) {
                 $matchThese["province"] = Auth::user()->province;
             }
         }
         if ($request->has('region')) {
             $matchThese["region"] = $request->region;
         } else {
             if (Auth::user()->region) {
                 $matchThese["region"] = Auth::user()->region;
             }
         }
         if ($request->has('municipality')) {
             $matchThese["municipality"] = $request->municipality;
         } else {
             if (Auth::user()->municipality) {
                 $matchThese["municipality"] = Auth::user()->municipality;
             }
         }
         if ($request->has('travelstatus')) {
             $matchThese["applicationstatus_id"] = $request->travelstatus;
         }
         if ($_POST['dateFrom'] != "" && $_POST['dateTo'] != "") {
             $dateFrom = new DateTime($_POST['dateFrom']);
             $dateTo = new DateTime($_POST['dateTo']);
             $dateFromString = $dateFrom->format('Y-m-d');
             $dateToString = $dateTo->format('Y-m-d') . " 23:59:00";
             $travelApplications = travelApplication::where($matchThese)->where('created_at', '<=', $dateToString)->where('created_at', '>=', $dateFromString)->orderBy('updated_at')->orderBy('updated_at', 'desc')->get();
         } else {
             $travelApplications = travelApplication::where($matchThese)->orderBy('updated_at', 'desc')->get();
         }
         $this->data['travelApplications'] = $travelApplications;
         return view('dashboard', $this->data);
     }
 }
开发者ID:abrenicamarkjoshua,项目名称:TravelDilg,代码行数:49,代码来源:HomeController.php


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