This commit is contained in:
Shohrat 2023-10-03 17:10:50 +05:00
parent 67554519a0
commit 11370fa043
2 changed files with 26 additions and 5 deletions

View File

@ -39,6 +39,7 @@ class Category extends Model
public $hasMany = [ public $hasMany = [
'filter_group' => ['TPS\Birzha\Models\FilterGroups', 'key' => 'category_id'], '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); 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){ public static function getMenuTypeInfo($type){
$result = []; $result = [];

View File

@ -53,9 +53,9 @@ class Product extends Model
]; ];
public $belongsTo = [ public $belongsTo = [
//'place' => City::class, 'place' => City::class,
'order_item' => OrderItems::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'], //'currency' => ['TPS\Birzha\Models\Currency'],
//'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'], //'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'],
//'delivery_term' => ['TPS\Birzha\Models\Term','key' => 'delivery_term_id'], //'delivery_term' => ['TPS\Birzha\Models\Term','key' => 'delivery_term_id'],
@ -100,6 +100,10 @@ class Product extends Model
return $query->where('status', 'approved'); 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) { public function scopeSearched($query, $locale, $queryString) {
if($locale == 'tm') { if($locale == 'tm') {