45 lines
998 B
PHP
45 lines
998 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Addon;
|
|
|
|
use App\Models\Addon;
|
|
use App\Repositories\BaseRepository;
|
|
|
|
class AddonRepository extends BaseRepository implements AddonRepositoryInterface
|
|
{
|
|
public function getModel()
|
|
{
|
|
return Addon::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();
|
|
}
|
|
} |