ldc-groupe/app/Models/DocumentCategory.php
2026-02-13 12:10:35 +01:00

74 lines
2.1 KiB
PHP

<?php
namespace App\Models;
use App\Contracts\TranslatableModel;
use App\Traits\Models\HasCache;
use App\Traits\Models\HasTranslations;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Uwil\LaravelActivityLogs\Traits\ActivityLog;
/**
* @property integer $id
* Id of the category.
* @property string $name
* Name of the category.
* @property string $slug
* Slug of the category.
* @property-read \Carbon\Carbon $created_at
* Created date of the category.
* @property-read \Carbon\Carbon $updated_at
* Updated date of the category.
* @property-read \Illuminate\Support\Carbon $deleted_at
* Deleted date of the category.
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* Associated documents of the category.
*/
class DocumentCategory extends Model implements TranslatableModel
{
use ActivityLog;
use HasFactory;
use HasCache;
use HasTranslations;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'slug'
];
/**
* The translatable columns.
*
* @var list<string>
*/
public $translatable = [
'name',
'slug'
];
// * RELATIONSHIPS
/**
* Associated documents of the category.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{
return $this->morphToMany(
Document::class,
'documentable',
'documentables',
'documentable_id',
'document_id'
);
}
}