Files
portal-api/app/Repositories/Payment/PaymentReppository.php
2025-07-24 16:18:27 +07:00

33 lines
913 B
PHP

<?php
namespace App\Repositories\Payment;
use App\Models\Payment;
use App\Repositories\BaseRepository;
class PaymentReppository extends BaseRepository implements PaymentReppositoryInterface
{
public function getModel()
{
return Payment::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 (isset($data['type'])) {
$model = $model->where("type", $data['type']);
}
if (count($withCount) > 0) {
$model = $model->withCount($withCount);
}
if(isset($data['page'])) {
return $model->paginate(15);
}
return $model->get();
}
}