40 lines
953 B
PHP
40 lines
953 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
use Spatie\Sluggable\HasSlug;
|
|
use Spatie\Sluggable\SlugOptions;
|
|
|
|
class Bottle extends Model implements HasMedia
|
|
{
|
|
use HasFactory, HasSlug, InteractsWithMedia, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'cost_price' => 'int',
|
|
'sale_price' => 'int',
|
|
];
|
|
}
|
|
|
|
public function getSlugOptions(): SlugOptions
|
|
{
|
|
return SlugOptions::create()
|
|
->generateSlugsFrom('name')
|
|
->saveSlugsTo('slug');
|
|
}
|
|
|
|
public function outlets(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Outlet::class);
|
|
}
|
|
}
|