53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\Module\DnsServer;
|
|
|
|
use App\Models\ModuleDnsServer;
|
|
use App\Repositories\BaseRepository;
|
|
|
|
class DnsServerRepository extends BaseRepository implements DnsServerRepositoryInterface
|
|
{
|
|
public function getModel()
|
|
{
|
|
return ModuleDnsServer::class;
|
|
}
|
|
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();
|
|
}
|
|
public function findByName(string $name = '')
|
|
{
|
|
if (empty($name)) {
|
|
return false;
|
|
}
|
|
return $this->model->where('name', 'LIKE', "%$name%")->first();
|
|
}
|
|
}
|