scopes
This commit is contained in:
parent
67554519a0
commit
11370fa043
|
|
@ -36,9 +36,10 @@ class Category extends Model
|
|||
];
|
||||
|
||||
public $translatable = ['name',['slug', 'index' => true]];
|
||||
|
||||
|
||||
public $hasMany = [
|
||||
'filter_group' => ['TPS\Birzha\Models\FilterGroups', 'key' => 'category_id'],
|
||||
'subs' => ['TPS\Birzha\Models\Category', 'key' => 'primary_key']
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -60,6 +61,22 @@ class Category extends Model
|
|||
return $query->where('status', 1);
|
||||
}
|
||||
|
||||
public function scopeActiveAndParent($query)
|
||||
{
|
||||
return $query->where('status', 1)->where('primary_key',0);
|
||||
}
|
||||
|
||||
|
||||
public function scopeActiveAndParentFirstFour($query)
|
||||
{
|
||||
return $query->where('status', 1)->where('primary_key', 0)->offset(0)->limit(4);
|
||||
}
|
||||
|
||||
public function scopeActiveAndParentLastFour($query)
|
||||
{
|
||||
return $query->where('status', 1)->where('primary_key', 0)->offset(4)->limit(8);
|
||||
}
|
||||
|
||||
public static function getMenuTypeInfo($type){
|
||||
$result = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -49,20 +49,20 @@ class Product extends Model
|
|||
public $belongsToMany = [
|
||||
'categories' => ['TPS\Birzha\Models\Category','table' => 'tps_birzha_product_categories'],
|
||||
//'favourites' => ['TPS\Birzha\Models\Favourites','table' => 'tps_birzha_favourites'],
|
||||
|
||||
|
||||
];
|
||||
|
||||
public $belongsTo = [
|
||||
//'place' => City::class,
|
||||
'place' => City::class,
|
||||
'order_item' => OrderItems::class,
|
||||
'place' => ['TPS\Birzha\Models\City','key' => 'place_id'],
|
||||
//'measure' => ['TPS\Birzha\Models\Measure','key' => 'measure_id'],
|
||||
//'currency' => ['TPS\Birzha\Models\Currency'],
|
||||
//'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'],
|
||||
//'delivery_term' => ['TPS\Birzha\Models\Term','key' => 'delivery_term_id'],
|
||||
'vendor' => User::class,
|
||||
//'payment' => ['TPS\Birzha\Models\Payment'],
|
||||
];
|
||||
|
||||
|
||||
public $hasMany = [
|
||||
'favourites' => ['TPS\Birzha\Models\Favourites', 'table' => 'tps_birzha_favourites'],
|
||||
'comments' => ['TPS\Birzha\Models\Comment','table' => 'tps_birzha_comments'],
|
||||
|
|
@ -100,6 +100,10 @@ class Product extends Model
|
|||
return $query->where('status', 'approved');
|
||||
}
|
||||
|
||||
public function scopeVipProducts($query, $type) {
|
||||
return $query->where('type', $type)->where('status', 'approved')->withCount("images");
|
||||
}
|
||||
|
||||
public function scopeSearched($query, $locale, $queryString) {
|
||||
|
||||
if($locale == 'tm') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue