當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Eloquent::where方法代碼示例

本文整理匯總了PHP中Eloquent::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Eloquent::where方法的具體用法?PHP Eloquent::where怎麽用?PHP Eloquent::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Eloquent的用法示例。


在下文中一共展示了Eloquent::where方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doColumnSearch

 /**
  * Perform column search
  *
  * @return void
  */
 public function doColumnSearch()
 {
     $input = $this->input;
     $columns = $input['columns'];
     // if older version, set the column name to query's fields
     // or if new version but does not use mData support
     if (!$this->new_version or !$this->mDataSupport and $this->new_version) {
         for ($i = 0; $i < count($columns); $i++) {
             if (!isset($this->columns[$i])) {
                 continue;
             }
             $columns[$i]['name'] = $this->columns[$i];
             if (stripos($columns[$i]['name'], ' AS ') !== false or $columns[$i]['name'] instanceof Expression) {
                 $columns[$i]['name'] = '';
                 $columns[$i]['searchable'] = false;
                 $columns[$i]['orderable'] = false;
             }
         }
     }
     for ($i = 0, $c = count($columns); $i < $c; $i++) {
         if ($columns[$i]['searchable'] == "true" and !empty($columns[$i]['search']['value']) and !empty($columns[$i]['name'])) {
             $column = $columns[$i]['name'];
             $keyword = $this->setupKeyword($columns[$i]['search']['value']);
             // wrap column possibly allow reserved words to be used as column
             $column = $this->wrapColumn($column);
             if ($this->isCaseInsensitive()) {
                 $this->query->whereRaw('LOWER(' . $column . ') LIKE ?', [strtolower($keyword)]);
             } else {
                 $col = strstr($column, '(') ? $this->connection->raw($column) : $column;
                 $this->query->where($col, 'LIKE', $keyword);
             }
         }
     }
 }
開發者ID:testoodoo,項目名稱:OoodooSiteUp,代碼行數:39,代碼來源:Datatables.php

示例2: validateOwnership

 protected function validateOwnership(Eloquent $model)
 {
     // Validate correct resource
     if ($model_id = Request::segment(2)) {
         $count = $model->where('id', $model_id)->where('user_id', Auth::id())->count();
         if ($count === 0) {
             return $this->respondNotFound();
         }
     }
 }
開發者ID:aaronbullard,項目名稱:litmus,代碼行數:10,代碼來源:BaseController.php

示例3: doColumnSearch

 /**
  * Perform column search
  *
  * @param  array $columns
  * @return void
  */
 public function doColumnSearch(array $columns)
 {
     for ($i = 0, $c = count($columns); $i < $c; $i++) {
         if ($columns[$i]['searchable'] == "true" and !empty($columns[$i]['search']['value']) and !empty($columns[$i]['name'])) {
             $column = $columns[$i]['name'];
             $keyword = $this->setupKeyword($columns[$i]['search']['value']);
             // wrap column possibly allow reserved words to be used as column
             $column = $this->wrapColumn($column);
             if ($this->isCaseInsensitive()) {
                 $this->query->whereRaw('LOWER(' . $column . ') LIKE ?', [strtolower($keyword)]);
             } else {
                 $col = strstr($column, '(') ? $this->connection->raw($column) : $column;
                 $this->query->where($col, 'LIKE', $keyword);
             }
         }
     }
 }
開發者ID:kimnv57,項目名稱:laravel-simple-api-ueter-aide,代碼行數:23,代碼來源:Datatables.php

示例4: addFilterRangeDate

 /**
  * Фильтр: диапазон дат
  *
  * @param      $form_field
  * @param      $label
  * @param null $db_field
  */
 function addFilterRangeDate($form_field, $label, $db_field = null)
 {
     if (!$db_field) {
         $db_field = $form_field;
     }
     $gr = $this->form->putTbGroup($form_field)->setLabel($label);
     $gr->putTbDate('from')->setLabel('С')->setWrapClass('col-md-6')->setAppendClear();
     $gr->putTbDate('to')->setLabel('по')->setWrapClass('col-md-6')->setAppendClear();
     $from = \Input::get($form_field . '.from');
     $to = \Input::get($form_field . '.to');
     if ($from) {
         $this->model->where(function ($query) use($db_field, $from) {
             $query->where($db_field, '>=', \Carbon\Carbon::parse($from)->format('Y-m-d H:i:s'));
         });
     }
     if ($to) {
         $this->model->where(function ($query) use($db_field, $to) {
             $query->where($db_field, '<=', \Carbon\Carbon::parse($to)->format('Y-m-d H:i:s'));
         });
     }
 }
開發者ID:larakit,項目名稱:lk,代碼行數:28,代碼來源:FormFilter.php

示例5: storeDelete

 /**
  * Delete a row with store_key
  *
  * @param $key
  * @return int
  */
 public static function storeDelete($key)
 {
     return parent::where(self::$storeColumn['key'], $key)->delete();
 }
開發者ID:mnking,項目名稱:june,代碼行數:10,代碼來源:BaseModel.php

示例6: getBySlug

 /**
  * @param string $slug
  * @return mixed
  */
 public function getBySlug($slug)
 {
     return $this->model->where('slug', $slug)->firstOrFail();
 }
開發者ID:floatingpointsoftware,項目名稱:grapevine,代碼行數:8,代碼來源:EloquentRepository.php

示例7: edit

 /**
  * Edit data by id
  * @param  mixed $value
  * @param  array $data
  * @param  string $field
  * @return int How many record has been changed
  */
 public function edit($value, array $data, $field = 'id')
 {
     $result = $this->model->where($field, $value)->update($data);
     return $result;
 }
開發者ID:sharenjoy,項目名稱:cmsharenjoy,代碼行數:12,代碼來源:EloquentBaseRepository.php


注:本文中的Eloquent::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。