Files

67 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2015-12-06 13:58:49 -05:00
<?php
2016-12-07 22:46:38 +00:00
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2015-12-06 13:58:49 -05:00
namespace Pterodactyl\Models;
2026-10-05 18:10:18 -04:00
use Database\Factories\SubuserFactory;
use Illuminate\Database\Eloquent\Attributes\Guarded;
2024-10-21 19:18:20 -06:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2026-10-05 18:10:18 -04:00
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Notifications\Notifiable;
use Pterodactyl\Models\Traits\HasHashid;
2015-12-06 13:58:49 -05:00
2019-11-03 12:20:11 -08:00
/**
2026-10-05 18:10:18 -04:00
* @property list<string> $permissions
2026-10-11 22:55:07 -04:00
* @property-read User $user
* @property-read Server $server
2019-11-03 12:20:11 -08:00
*/
2026-10-05 18:10:18 -04:00
#[Guarded(['id', 'created_at', 'updated_at'])]
class Subuser extends Model
2015-12-06 13:58:49 -05:00
{
2026-10-05 18:10:18 -04:00
/** @use HasFactory<SubuserFactory> */
2024-10-21 19:18:20 -06:00
use HasFactory;
2026-10-05 18:10:18 -04:00
use HasHashid;
use Notifiable;
2026-10-05 18:10:18 -04:00
public const string RESOURCE_NAME = 'server_subuser';
2017-08-23 21:34:11 -05:00
2017-10-27 21:42:53 -05:00
/**
2026-10-05 18:10:18 -04:00
* @return array<string, string>
2017-10-27 21:42:53 -05:00
*/
2026-10-05 18:10:18 -04:00
protected function casts(): array
2017-10-27 21:42:53 -05:00
{
2026-10-05 18:10:18 -04:00
return [
'user_id' => 'int',
'server_id' => 'int',
'permissions' => 'array',
];
2017-10-27 21:42:53 -05:00
}
/**
2026-10-05 18:10:18 -04:00
* @return BelongsTo<Server, $this>
*/
2022-10-14 10:59:20 -06:00
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
/**
2026-10-05 18:10:18 -04:00
* @return BelongsTo<User, $this>
*/
2022-10-14 10:59:20 -06:00
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
2017-02-09 18:44:07 -05:00
/**
2026-10-05 18:10:18 -04:00
* @return HasMany<Permission, $this>
2017-02-09 18:44:07 -05:00
*/
2022-10-14 10:59:20 -06:00
public function permissions(): HasMany
2017-02-09 18:44:07 -05:00
{
2017-02-09 19:38:54 -05:00
return $this->hasMany(Permission::class);
2017-02-09 18:44:07 -05:00
}
2015-12-06 13:58:49 -05:00
}