misc_pterodactyl-panel/app/Models/AdminRole.php

60 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2022-12-15 00:05:46 +00:00
<?php
namespace Pterodactyl\Models;
2022-12-15 01:04:16 +00:00
use Illuminate\Database\Eloquent\Relations\HasMany;
2022-12-15 00:05:46 +00:00
/**
* @property int $id
* @property string $name
* @property string|null $description
* @property int $sort_id
* @property array $permissions
*/
class AdminRole extends Model
{
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
public const RESOURCE_NAME = 'admin_role';
/**
* The table associated with the model.
*/
protected $table = 'admin_roles';
/**
* Fields that are mass assignable.
*/
protected $fillable = [
'name',
'description',
'sort_id',
];
/**
* Cast values to correct type.
*/
protected $casts = [
'sort_id' => 'int',
'permissions' => 'array',
];
public static array $validationRules = [
'name' => 'required|string|max:64',
'description' => 'nullable|string|max:255',
'sort_id' => 'sometimes|numeric',
];
public $timestamps = false;
/**
2022-12-15 01:04:16 +00:00
* Gets the permissions associated with an admin role.
2022-12-15 00:05:46 +00:00
*/
2022-12-15 01:04:16 +00:00
public function permissions(): HasMany
2022-12-15 00:05:46 +00:00
{
return $this->hasMany(Permission::class);
}
}