Files
2026-02-04 09:49:48 +07:00

57 lines
1.3 KiB
PHP

<?php
namespace App\Repositories\Module\HostingServer;
use App\Models\ModuleHostingServer;
use App\Repositories\BaseRepository;
class HostingServerRepository extends BaseRepository implements HostingServerRepositoryInterface
{
public function getModel()
{
return ModuleHostingServer::class;
}
public function get_active()
{
return $this->model->isActive();
}
public function findByName(string $name = '')
{
if (empty($name)) {
return false;
}
return $this->model->where('name', 'LIKE', "%$name%")->first();
}
public function filter(
array $data = [],
array $relationships = [],
array $withCount = [],
array $select = ['*'],
bool $returnQuery = false
) {
$query = $this->model
->select($select)
->with($relationships);
// if (!empty($data['vcenter_id'])) {
// $query->where('vcenter_id', $data['vcenter_id']);
// }
if (!empty($withCount)) {
$query->withCount($withCount);
}
if ($returnQuery) {
return $query;
}
if (!empty($data['paginate'])) {
return $query->paginate(
$data['per_page'] ?? 15
);
}
return $query->get();
}
}