Xboard/app/Models/ServerGroup.php
2025-01-07 01:20:11 +08:00

27 lines
576 B
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ServerGroup extends Model
{
protected $table = 'v2_server_group';
protected $dateFormat = 'U';
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp'
];
public function users(): HasMany
{
return $this->hasMany(User::class, 'group_id', 'id');
}
public function servers()
{
return Server::whereJsonContains('group_ids', (string) $this->id)->get();
}
}