Example #1
0
 /**
  * Add a whereIn to the query
  *
  * @param  string $field
  * @param  array  $values
  * @param  bool   $order
  *
  * @return $this
  */
 public function whereIn($field, $values, $order = false)
 {
     $this->builder = $this->builder->whereIn($field, $values);
     if ($order) {
         $this->builder = $this->builder->orderByRaw(DB::raw("FIELD(" . $field . ", " . implode(',', $values) . ")"));
     }
     return $this;
 }
Example #2
0
 public function scopeHighestRes(Builder $query)
 {
     return $query->orderByRaw('(width * height) DESC');
 }
Example #3
0
 /**
  * Order entries in a specific order.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param string                                $field
  * @param array                                 $values
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeOrderByField($query, $field, $values)
 {
     return $query->orderByRaw($field . ' <> "' . implode('", ' . $field . ' <> "', $values) . '"');
 }