コード例 #1
0
ファイル: HasMany.php プロジェクト: SerdarSanri/admin
 /**
  * Filters a query object with this item's data given a model
  *
  * @param Query		$query
  * @param Eloquent	$model
  *
  * @return void
  */
 public function filterQuery(&$query, $model)
 {
     //run the parent method
     parent::filterQuery($query, $model);
     //if there is no value, return
     if (!$this->value) {
         return;
     }
     //if the table hasn't been joined yet, join it
     if (!Column::isJoined($query, $this->table)) {
         $query->join($this->table, $model->table() . '.' . $model::$key, '=', $this->table . '.' . $this->column);
     }
     $query->where_in($this->table . '.id', is_array($this->value) ? $this->value : array($this->value));
 }
コード例 #2
0
 /**
  * Constrains a query by a given set of constraints
  *
  * @param  Query 		$query
  * @param  Eloquent 	$model
  * @param  array 		$constraints
  *
  * @return void
  */
 public function constrainQuery(&$query, $model, $constraints)
 {
     //if the column hasn't been joined yet, join it
     if (!Column::isJoined($query, $this->table)) {
         $query->join($this->table, $model->table() . '.' . $model::$key, '=', $this->column2);
     }
     $query->where($this->column, '=', $constraints);
 }