Updates to 03-2025
This commit is contained in:
parent
6167273a48
commit
9b54eb0512
348 changed files with 34535 additions and 5774 deletions
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Services\Type;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
|
||||
|
|
@ -27,7 +28,6 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $product_categories
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category findSimilarSlugs($attribute, $config, $slug)
|
||||
|
|
@ -47,6 +47,9 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @property-read \App\Models\IqImage|null $iq_image
|
||||
* @property-read int|null $product_categories_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @property array|null $show_on
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereShowOn($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
|
@ -60,7 +63,7 @@ class Category extends Model
|
|||
'parent_id', 'name', 'headline', 'pos', 'active', 'show_on'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
@ -134,15 +137,21 @@ class Category extends Model
|
|||
return rtrim($ret, ', ');
|
||||
}
|
||||
|
||||
public function getShowOnTypes(){
|
||||
public function getShowOnTypes($seperator = false){
|
||||
$ret = [];
|
||||
if($this->show_on && is_array($this->show_on)){
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
return $seperator ? implode($seperator, $ret) : $ret;
|
||||
}
|
||||
public function getProductsCountOn($show_on = ['8']){
|
||||
$category_id = $this->id;
|
||||
return Product::where('active', true)->whereJsonContains('show_on', $show_on)
|
||||
->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('category_id', $category_id); //
|
||||
})->orderBy('pos', 'ASC')->count();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue