update deploy
This commit is contained in:
48
app/Repositories/Eloquent/LeadRepository.php
Normal file
48
app/Repositories/Eloquent/LeadRepository.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Eloquent;
|
||||
|
||||
use App\Models\Lead;
|
||||
use App\Repositories\Contracts\LeadRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @extends BaseRepository<Lead>
|
||||
*/
|
||||
class LeadRepository extends BaseRepository implements LeadRepositoryInterface
|
||||
{
|
||||
public function __construct(Lead $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $filters
|
||||
* @return LengthAwarePaginator<int, Lead>
|
||||
*/
|
||||
public function paginate(array $filters = [], int $perPage = 15): LengthAwarePaginator
|
||||
{
|
||||
$query = $this->model->newQuery();
|
||||
|
||||
if (! empty($filters['status'])) {
|
||||
$query->where('status', $filters['status']);
|
||||
}
|
||||
|
||||
if (! empty($filters['source'])) {
|
||||
$query->where('source', $filters['source']);
|
||||
}
|
||||
|
||||
if (isset($filters['is_read'])) {
|
||||
$query->where('is_read', filter_var($filters['is_read'], FILTER_VALIDATE_BOOLEAN));
|
||||
}
|
||||
|
||||
if (! empty($filters['search'])) {
|
||||
$query->where(function ($q) use ($filters) {
|
||||
$q->where('name', 'like', '%'.$filters['search'].'%')
|
||||
->orWhere('phone', 'like', '%'.$filters['search'].'%');
|
||||
});
|
||||
}
|
||||
|
||||
return $query->latest()->paginate($perPage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user