Xboard/app/Models/ServerGroup.php

27 lines
576 B
PHP
Raw Normal View History

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