Bozz
Bozz
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
I use filament v3
19 replies
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
I use filament v3
19 replies
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
I hope you're doing well. I used Laravel Breeze for user registration and login and then added a form to the Livewire component (the filament form bulder), for the user profile, but when submitting the form, the page reloads and nothing is saved in the database and the fields are reset. here are the important files thank you for helping me.
19 replies
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
no, the problem has not been resolved
19 replies
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
No description
19 replies
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
good evening sir @tuto1902 , I made the modifications in my code according to your explanation, but I have an error: """ Class "Filament\Panel\PanelServiceProvider" not found """ here are the modifications made: 1 - To display only the information of the currently logged in user in the user dashboard, I used global scopes and policies. First, I create a middleware class called AssignGlobalScopes that applies a global scope to each request. This global scope will filter data based on the currently authenticated user: class AssignGlobalScopes { public function handle(Request $request, Closure $next): Response { User::addGlobalScope(function (Builder $query) { $query->whereBelongsTo(Filament::auth()->user(), 'owner'); }); return $next($request); } } 2 - Next, I created a policy class called UserPolicy which only allows administrators to update users: class UserPolicy { public function update(): bool { return auth()->user()->role->name == 'admin'; } } 3 - I saved the policy in the AuthServiceProvider: class AuthServiceProvider extends ServiceProvider { protected $policies = [ User::class => UserPolicy::class ]; } 4 - Finally, apply the middleware and policy to your UserPanelProvider: class UserPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel // ... ->middleware([ // ... AssignGlobalScopes::class ]) ->policy(User::class, UserPolicy::class); } } I attach below the code of the modifications made
19 replies
TLCTuto's Laravel Corner
Created by Bozz on 9/28/2023 in #💡filament
display information about the logged in user at the user resource level
No description
19 replies