<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;

class Role extends Model
{
    use HasFactory;
    use LogsActivity;

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults();
   }

    protected $fillable = [
        'name'
    ];

    public function permissions(){
        return $this->belongsToMany(Permission::class, "role_permission")
            ->select("id","code","name");
    }

    public function users(){
        return $this->hasMany(User::class,"role_id");
    }
}
