41 lines
749 B
PHP
41 lines
749 B
PHP
<?php
|
|
|
|
namespace App\Models\Permissions;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Permission extends Model
|
|
{
|
|
public $timestamps = false;
|
|
protected $fillable = [
|
|
'string_id',
|
|
'parent_id',
|
|
'group',
|
|
'name',
|
|
'default'
|
|
];
|
|
protected $casts = [
|
|
'default' => 'boolean'
|
|
];
|
|
|
|
/**
|
|
* Assign observer for this model for logging
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
self::observe(PermissionObserver::class);
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->hasOne(Permission::class, 'parent_id');
|
|
}
|
|
|
|
public function subpermissions()
|
|
{
|
|
return $this->hasMany(Permission::class, 'parent_id');
|
|
}
|
|
}
|