Add thumbs views in datatables with traits
This commit is contained in:
@@ -16,7 +16,7 @@ use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
use App\Traits\HasComments;
|
||||
use App\Traits\Model\HasComments;
|
||||
|
||||
class Article extends Model implements HasMedia
|
||||
{
|
||||
@@ -70,11 +70,9 @@ class Article extends Model implements HasMedia
|
||||
return $query->where($this->table . '.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
public function scopeByAutocomplete($query, $str)
|
||||
{
|
||||
return $query->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('id', $category_id);
|
||||
});
|
||||
return $query->where($this->table . '.name', 'LIKE', "%${str}%");
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
@@ -82,6 +80,13 @@ class Article extends Model implements HasMedia
|
||||
return $query->where($this->table . '.article_nature_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('id', $category_id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $model)
|
||||
{
|
||||
return $query->where($this->table . '.product_type', $model);
|
||||
|
||||
Reference in New Issue
Block a user