<?php

namespace App\Models;

use App\Enums\Status;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class AdminPermission extends BaseModel
{
    protected $table = 'admin_permissions';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'name',
        'code',
        'module',
        'app_id',
        'status',
    ];

    protected $casts = [
        'status' => Status::class,
    ];

    public function roles(): BelongsToMany
    {
        return $this->belongsToMany(AdminRole::class, 'admin_role_permissions', 'permission_id', 'role_id');
    }
}
