ldc-supportweb/app/Models/Brand.php

76 lines
2 KiB
PHP
Raw Normal View History

2026-05-19 16:44:38 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Uwil\LaravelActivityLogs\Traits\HasActivityLog;
use Uwil\LaravelBackend\Traits\Models\HasCache;
use Uwil\LaravelBackend\Traits\Models\HasModelNaming;
use Uwil\LaravelI18n\Traits\Models\HasTranslations;
/**
* @property integer $id Primary key of the brand.
* @property string $name Name of the brand.
* @property-read \Illuminate\Support\Carbon $created_at Date the brand was created.
* @property-read \Illuminate\Support\Carbon $updated_at Date the brand was updated.
* @property-read \Illuminate\Support\Carbon $deleted_at Date the brand was deleted.
2026-05-19 16:44:38 +02:00
*/
class Brand extends Model
{
use HasActivityLog;
use HasCache;
/** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\BrandFactory> */
use HasFactory;
use HasModelNaming;
use HasTranslations;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
2026-05-26 13:12:45 +02:00
#[\Override]
2026-05-19 16:44:38 +02:00
protected $fillable = [
'name',
];
/**
* The translatable columns.
*
* @var list<string>
*/
public $translatable = [
'name',
];
/**
2026-05-26 13:12:45 +02:00
* Get relations to include in the cache.
*
2026-05-26 13:12:45 +02:00
* @return list<string>
*/
2026-05-26 13:12:45 +02:00
public static function getCacheRelations(): array
{
return ['sites'];
}
2026-05-19 16:44:38 +02:00
// * RELATIONS.
/**
* Get sites associated to the brand.
*
2026-05-26 13:12:45 +02:00
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'>
2026-05-19 16:44:38 +02:00
*/
public function sites(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{
return $this->morphToMany(
Site::class,
'sitable',
'sitables',
'sitable_id',
'site_id',
)->withPivot('created_at');
}
}