29 lines
635 B
PHP
29 lines
635 B
PHP
<?php
|
|
|
|
namespace App\Features\Consoles\Repositories;
|
|
|
|
use App\Features\Consoles\Models\Console;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
class ConsoleRepository
|
|
{
|
|
public function __construct(
|
|
private Console $model
|
|
) {}
|
|
|
|
public function getAll(): Collection
|
|
{
|
|
return $this->model->withCount('games')->orderBy('name')->get();
|
|
}
|
|
|
|
public function getBySlug(string $slug): ?Console
|
|
{
|
|
return $this->model->where('slug', $slug)->first();
|
|
}
|
|
|
|
public function getWithGamesCount(): Collection
|
|
{
|
|
return $this->model->withCount('games')->orderBy('name')->get();
|
|
}
|
|
}
|