Added filters for projects
This commit is contained in:
@@ -11,7 +11,7 @@ use Illuminate\Support\Collection;
|
||||
interface ProjectRepository
|
||||
{
|
||||
|
||||
public function all(): Collection;
|
||||
public function all(array $filters = []): Collection;
|
||||
public function get(int $id): ProjectResource;
|
||||
public function update(Project $project, array $data = []): bool;
|
||||
public function create(array $data = []): Project;
|
||||
|
@@ -8,6 +8,7 @@ use App\Http\Resources\ProjectCollection;
|
||||
use App\Http\Resources\ProjectResource;
|
||||
use App\Models\Project;
|
||||
use App\Repository\Interfaces\ProjectRepository as ProjectRepositoryInterface;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ProjectRepository implements ProjectRepositoryInterface
|
||||
@@ -19,12 +20,17 @@ class ProjectRepository implements ProjectRepositoryInterface
|
||||
private Project $project
|
||||
) {}
|
||||
|
||||
public function all(): Collection
|
||||
public function all(array $filters = []): Collection
|
||||
{
|
||||
$project = $this->project
|
||||
->query()
|
||||
->orderBy('release_data', 'ASC');
|
||||
|
||||
foreach ($filters as $filter_name => $filter_value) {
|
||||
if ($filter_name === 'category' && $filter_value !== 'all')
|
||||
$project->where('categories', 'like', '%"'. $filter_value .'"%');
|
||||
}
|
||||
|
||||
if (!$this->auth)
|
||||
$project->visibled();
|
||||
|
||||
|
Reference in New Issue
Block a user