updates for admin area

This commit is contained in:
Mark Gregory
2026-09-12 21:04:45 +01:00
parent 8c9dbfee08
commit ab3134de13
43 changed files with 573 additions and 137 deletions
+23 -9
View File
@@ -4,26 +4,40 @@ namespace App\Http\Controllers;
use App\Models\DjProfile;
use Illuminate\Http\Request;
use Illuminate\View\View;
class DjController extends Controller
{
public function index(Request $r)
public function index(Request $request): View
{
$q = DjProfile::query()->where('is_published', true)->with('genres');
if ($r->filled('location')) {
$q->where('city', 'like', '%'.$r->string('location').'%');
} if ($r->filled('max_price')) {
$q->where('price_from', '<=', $r->integer('max_price'));
$query = DjProfile::query()->where('is_published', true)->with('genres');
if ($request->filled('location')) {
$query->where('city', 'like', '%'.$request->string('location').'%');
}
return view('djs.index', ['djs' => $q->orderByDesc('is_featured')->orderByDesc('average_rating')->paginate(12)->withQueryString()]);
if ($request->filled('max_price')) {
$query->where('price_from', '<=', $request->integer('max_price'));
}
$query->orderByDesc('is_featured');
match ($request->string('sort')->toString()) {
'price_low' => $query->orderBy('price_from'),
'price_high' => $query->orderByDesc('price_from'),
default => $query->orderByDesc('average_rating'),
};
return view('djs.index', ['djs' => $query->paginate(12)->withQueryString()]);
}
public function show(DjProfile $djProfile)
public function show(DjProfile $djProfile): View
{
abort_unless($djProfile->is_published, 404);
return view('djs.show', ['dj' => $djProfile->load(['genres', 'reviews' => fn ($q) => $q->where('status', 'published')->latest()])]);
return view('djs.show', [
'dj' => $djProfile->load(['genres', 'reviews' => fn ($query) => $query->where('status', 'published')->latest()]),
]);
}
public function apiIndex()