37 lines
993 B
PHP
37 lines
993 B
PHP
<?php
|
|
|
|
namespace App\Repositories\vCenter;
|
|
|
|
use App\Models\vCenter;
|
|
use App\Repositories\BaseRepository;
|
|
|
|
class vCenterRepository extends BaseRepository implements vCenterRepositoryInterface
|
|
{
|
|
public function getModel()
|
|
{
|
|
return vCenter::class;
|
|
}
|
|
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
|
{
|
|
$model = $this->model->with($relationships)->select($select);
|
|
|
|
if (isset($data['status'])) {
|
|
$model = $model->where("status", $data['status']);
|
|
}
|
|
if (count($withCount) > 0) {
|
|
$model = $model->withCount($withCount);
|
|
}
|
|
if(isset($data['page'])) {
|
|
return $model->paginate(15);
|
|
}
|
|
return $model->get();
|
|
}
|
|
public function findByName(string $name = '')
|
|
{
|
|
if (empty($name)) {
|
|
return false;
|
|
}
|
|
return $this->model->where('host','LIKE',"%$name%")->first();
|
|
}
|
|
}
|