74 lines
1.9 KiB
PHP
74 lines
1.9 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 Id 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>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
];
|
|
|
|
/**
|
|
* The translatable columns.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
public $translatable = [
|
|
'name',
|
|
];
|
|
|
|
/**
|
|
* Relations should be included in the cache.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
public static $cacheRelations = [
|
|
'sites',
|
|
];
|
|
|
|
// * RELATIONS.
|
|
|
|
/**
|
|
* Get sites associated to the brand.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site>
|
|
*/
|
|
public function sites(): \Illuminate\Database\Eloquent\Relations\MorphToMany
|
|
{
|
|
return $this->morphToMany(
|
|
Site::class,
|
|
'sitable',
|
|
'sitables',
|
|
'sitable_id',
|
|
'site_id',
|
|
)->withPivot('created_at');
|
|
}
|
|
}
|