2022-11-23 09:32:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Permission extends Model
|
|
|
|
{
|
|
|
|
protected $table = 'permissions';
|
|
|
|
protected $primaryKey = 'permission_id';
|
|
|
|
protected $fillable = [
|
|
|
|
'permission_name',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $hidden = [
|
|
|
|
'created_at',
|
|
|
|
'updated_at',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function users()
|
|
|
|
{
|
2022-12-08 09:30:07 +01:00
|
|
|
return $this->belongsToMany('App\Models\User', 'user_permissions', 'permission_id', 'user_id');
|
2022-11-23 09:32:34 +01:00
|
|
|
}
|
|
|
|
|
2023-02-02 08:17:38 +01:00
|
|
|
public function find(mixed $permission_id)
|
|
|
|
{
|
|
|
|
return $this->where('permission_id', $permission_id)->first();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create(array $array)
|
|
|
|
{
|
|
|
|
$this->permission_name = $array['permission_name'];
|
|
|
|
$this->save();
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2022-11-23 09:32:34 +01:00
|
|
|
}
|