Files
moonwell-web/app/Models/ShopProduct.php
T

34 lines
794 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class ShopProduct extends Model
{
protected $connection = 'store';
protected $table = 'store_services';
public $timestamps = false;
protected $guarded = ['id'];
protected function casts(): array
{
return ['price' => 'integer', 'discountAmount' => 'integer', 'new' => 'bool', 'enabled' => 'bool'];
}
public function categories(): BelongsToMany
{
return $this->belongsToMany(ShopCategory::class, 'store_category_service_link', 'service', 'category');
}
public function scopeOrdered(Builder $query): Builder
{
return $query->orderBy('id');
}
}