You've already forked Atomcms-edit
58 lines
1.4 KiB
PHP
Executable File
58 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models\Game;
|
|
|
|
use App\Models\Compositions\HasBadge;
|
|
use App\Models\StaffApplication;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $rank_name
|
|
* @property string $badge
|
|
* @property-read Collection<int, User> $users
|
|
* @property-read Collection<int, PermissionRole> $roles
|
|
* @property-read Collection<int, StaffApplication> $staffApplications
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Permission where($column, $operator = null, $value = null)
|
|
*/
|
|
class Permission extends Model implements HasBadge
|
|
{
|
|
#[\Override]
|
|
protected $table = 'permissions';
|
|
|
|
#[\Override]
|
|
public $timestamps = false;
|
|
|
|
#[\Override]
|
|
protected $guarded = ['id', 'rank_name'];
|
|
|
|
public function users(): HasMany
|
|
{
|
|
return $this->hasMany(User::class, 'rank', 'id');
|
|
}
|
|
|
|
public function roles(): HasMany
|
|
{
|
|
return $this->hasMany(PermissionRole::class);
|
|
}
|
|
|
|
public function staffApplications(): HasMany
|
|
{
|
|
return $this->hasMany(StaffApplication::class, 'rank_id');
|
|
}
|
|
|
|
public function getBadgePath(): string
|
|
{
|
|
return sprintf('%s%s.gif', setting('badges_path'), $this->getBadgeName());
|
|
}
|
|
|
|
public function getBadgeName(): string
|
|
{
|
|
return $this->badge;
|
|
}
|
|
}
|