generated from liutk/owl-admin-base
26 lines
590 B
PHP
26 lines
590 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Slowlyo\OwlAdmin\Admin;
|
|
use Slowlyo\OwlAdmin\Models\AdminRole as Model;
|
|
|
|
class AdminRole extends Model
|
|
{
|
|
protected static function boot(): void
|
|
{
|
|
parent::boot();
|
|
|
|
static::deleting(function (AdminRole $model) {
|
|
$model->menus()->detach();
|
|
$model->permissions()->detach();
|
|
});
|
|
}
|
|
|
|
public function menus(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Admin::adminMenuModel(), 'admin_role_menus', 'role_id', 'menu_id');
|
|
}
|
|
}
|