47 lines
975 B
PHP
47 lines
975 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property int|null $parent_id
|
|
* @property int|null $position
|
|
* @property int $max_size_kb
|
|
* @property bool $is_active
|
|
* @mixin \Eloquent
|
|
*/
|
|
class AttachmentGroup extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'parent_id',
|
|
'position',
|
|
'max_size_kb',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'bool',
|
|
];
|
|
|
|
public function extensions(): HasMany
|
|
{
|
|
return $this->hasMany(AttachmentExtension::class, 'attachment_group_id');
|
|
}
|
|
|
|
public function parent(): BelongsTo
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function children(): HasMany
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id');
|
|
}
|
|
}
|