<?php

namespace App\Models;

use App\Enums\UserTypeEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @property int $id
 * @property UserTypeEnum $user_type
 * @property int $permission_id
 * @property int $bits
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property-read \App\Models\Permission $permission
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission query()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission whereBits($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission wherePermissionId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission whereUserType($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission withTrashed(bool $withTrashed = true)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|UserTypePermission withoutTrashed()
 * @mixin \Eloquent
 */
class UserTypePermission extends Model
{
    use HasFactory, SoftDeletes;

    protected $guarded = ['id'];

    /**
     * The attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'permission_id' => 'integer',
            'user_type'     => UserTypeEnum::class,
            'bits'          => 'integer',
        ];
    }

    public function permission(): BelongsTo
    {
        return $this->belongsTo(Permission::class);
    }
}
