F
Filament2mo ago
MZX

What part of code signifies which panel does a page belong to?

I have 2 panels, one guest and one admin. Guest panel has quizzes on them. Some quizzes need Auth, so for the ones that do, I redirect them to a quiz page on the admin panel but it doesn't ask for auth (which means that page belongs to the Guest panel, even though i chose Admin panel when creating the page)
4 Replies
Dan Harrin
Dan Harrin2mo ago
the url dictates which panel is using a resource, a resource can belong to multiple panels
MZX
MZX2mo ago
the url is set for both the panels, but the page under admin isn't really under the admin panel because if it was it would ask for auth
Route::get('/guest/quiz/{quiz}', showquiz::class)->name('showquiz');

Route::get('/admin/quiz/{quiz}', showquizauth::class)->name('showquizauth');
Route::get('/guest/quiz/{quiz}', showquiz::class)->name('showquiz');

Route::get('/admin/quiz/{quiz}', showquizauth::class)->name('showquizauth');
the first one works fine because guest panel is the default panel, but the second one doesn't If everything was working right then on the second route it should ask me for Auth first
Dan Harrin
Dan Harrin2mo ago
you need to apply the auth middleware to the second endpoint then?
MZX
MZX2mo ago
Well that isn't what I am trying to do. showquiz, and showquiz auth are both the same filament pages. Except that showquiz belongs to guest (guest panel has no auth), and showquizauth belongs to admin (which has auth)
@foreach($quizzes as $quiz)
@php
// Determine the route based on the reqAuth property
$route = $quiz->reqAuth ? route('showquizauth', $quiz) : route('showquiz', $quiz);
@endphp
<a
href="{{ $route }}"
class="flex items-start gap-4 rounded-lg bg-white p-6 shadow-lg transition duration-100 hover:text-black/80 hover:bg-blue-100"
>
{{ $quiz->name }}
</a>
@endforeach
@foreach($quizzes as $quiz)
@php
// Determine the route based on the reqAuth property
$route = $quiz->reqAuth ? route('showquizauth', $quiz) : route('showquiz', $quiz);
@endphp
<a
href="{{ $route }}"
class="flex items-start gap-4 rounded-lg bg-white p-6 shadow-lg transition duration-100 hover:text-black/80 hover:bg-blue-100"
>
{{ $quiz->name }}
</a>
@endforeach
So a user would go on the guest panel by default where he sees all the quizzes. If a quiz requires auth, it will redirect to the showquiz auth page which belongs to the admin panel. and since admin panel requires auth, it should ask for auth too.