34 lines
822 B
PHP
34 lines
822 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class ShopCategory extends Model
|
|
{
|
|
protected $connection = 'store';
|
|
|
|
protected $table = 'store_categories';
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = ['name', 'icon', 'requiredRank', 'flags', 'enabled'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['requiredRank' => 'integer', 'flags' => 'integer', 'enabled' => 'bool'];
|
|
}
|
|
|
|
public function products(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(ShopProduct::class, 'store_category_service_link', 'category', 'service');
|
|
}
|
|
|
|
public function scopeOrdered(Builder $query): Builder
|
|
{
|
|
return $query->orderBy('id');
|
|
}
|
|
}
|