ldc-supportweb/app/Models/Brand.php
2026-05-28 10:50:21 +02:00

75 lines
2 KiB
PHP

<?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.
*/
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>
*/
#[\Override]
protected $fillable = [
'name',
];
/**
* The translatable columns.
*
* @var list<string>
*/
public $translatable = [
'name',
];
/**
* Get relations to include in the cache.
*
* @return list<string>
*/
public static function getCacheRelations(): array
{
return ['sites'];
}
// * RELATIONS.
/**
* Get sites associated to the brand.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'>
*/
public function sites(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{
return $this->morphToMany(
Site::class,
'sitable',
'sitables',
'sitable_id',
'site_id',
)->withPivot('created_at');
}
}