searchable; $query->where(function ($query) use ($fields, $search) { $query->where(array_shift($fields), 'LIKE', "%$search%"); foreach ($fields as $field) { $query->orWhere($field, 'LIKE', "$search%"); } }); } return $query; } /** * Local scope to filter subscribers by search/query string * @param ModelQueryBuilder $query * @param array $statuses * @return ModelQueryBuilder */ public function scopeProductBy($query, $productId) { if ($productId) { $query->where('product_id', $productId); } return $query; } /** * One2Many: Customer has to many Click Tickets * @return Model Collection */ public function person() { $class = __NAMESPACE__ . '\Person'; return $this->belongsTo( $class, 'created_by', 'id' ); } /** * One2Many: Customer has to many Click Tickets * @return Model Collection */ public function product() { $class = __NAMESPACE__ . '\Product'; return $this->belongsTo( $class, 'product_id', 'id' ); } }