__call() public method

Dynamically handle calls into the query instance.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
return mixed
Beispiel #1
0
 /**
  * Dynamically handle calls into the query instance.
  * @param  string  $method
  * @param  array   $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     if ($this->model->methodExists($scope = 'scope' . ucfirst($method))) {
         return $this->callScope($scope, $parameters);
     }
     return parent::__call($method, $parameters);
 }
Beispiel #2
0
 /**
  * Dynamically handle calls into the query instance.
  *
  * @param  string  $method
  * @param  array   $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     $scopeMethod = 'scope' . ucfirst($method);
     if (method_exists($this->repository, $scopeMethod)) {
         return $this->callRepositoryScope($scopeMethod, $parameters);
     }
     return parent::__call($method, $parameters);
 }
 public function __call($method, $parameters)
 {
     if (in_array($method, $this->_where_meta_methods)) {
         $db = DB::table($this->_meta_table)->where('meta_key', $parameters[0]);
         if (in_array($method, ['whereMeta', 'orWhereMeta'])) {
             $db->where('meta_value', $parameters[1], $parameters[2]);
         } else {
             if ($method == 'whereBetweenMeta') {
                 $db->whereBetween('meta_value', $parameters[1]);
             } else {
                 if ($method == 'whereNotBetweenMeta') {
                     $db->whereNotBetween('meta_value', $parameters[1]);
                 } else {
                     if ($method == 'whereInMeta') {
                         $db->whereIn('meta_value', $parameters[1]);
                     } else {
                         if ($method == 'whereNotInMeta') {
                             $db->whereNotIn('meta_value', $parameters[1]);
                         } else {
                             if ($method == 'whereNullMeta') {
                                 $db->where('type', 'null');
                             } else {
                                 if ($method == 'whereNotNullMeta') {
                                     $db->where('type', '<>', 'null');
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $parent_ids = $db->lists('parent_id');
         if ($method == 'orWhereMeta') {
             return $this->orWhere(function ($query) use($parent_ids) {
                 return $query->whereIn('id', $parent_ids);
             });
         }
         return $this->whereIn('id', $parent_ids);
     }
     return parent::__call($method, $parameters);
 }