71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\OutletStatus;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
use Spatie\Sluggable\HasSlug;
|
|
use Spatie\Sluggable\SlugOptions;
|
|
|
|
class Outlet extends Model implements HasMedia
|
|
{
|
|
use HasFactory, HasSlug, InteractsWithMedia, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => OutletStatus::class,
|
|
];
|
|
}
|
|
|
|
public function getSlugOptions(): SlugOptions
|
|
{
|
|
return SlugOptions::create()
|
|
->generateSlugsFrom('name')
|
|
->saveSlugsTo('slug');
|
|
}
|
|
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class, 'user_outlet')->withPivot('position_id');
|
|
}
|
|
|
|
public function openingHours(): HasMany
|
|
{
|
|
return $this->hasMany(OpeningHour::class);
|
|
}
|
|
|
|
public function facilities(): HasMany
|
|
{
|
|
return $this->hasMany(Facility::class);
|
|
}
|
|
|
|
public function vouchers(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Voucher::class);
|
|
}
|
|
|
|
public function perfumes(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Perfume::class);
|
|
}
|
|
|
|
public function products(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Product::class);
|
|
}
|
|
|
|
public function bottles(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Bottle::class);
|
|
}
|
|
}
|