File tree Expand file tree Collapse file tree 6 files changed +22
-3
lines changed
Http/Controllers/Settings Expand file tree Collapse file tree 6 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1010use Illuminate \Http \RedirectResponse ;
1111use Illuminate \Http \Request ;
1212use Illuminate \Support \Facades \Auth ;
13+ use Illuminate \Support \Facades \Log ;
1314use Inertia \Inertia ;
1415use Inertia \Response ;
1516
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ protected function casts(): array
4646 return [
4747 'email_verified_at ' => 'datetime ' ,
4848 'password ' => 'hashed ' ,
49+ 'is_admin ' => 'boolean ' ,
4950 ];
5051 }
5152}
Original file line number Diff line number Diff line change 11<?php
22
3- declare (strict_types = 1 );
3+ declare (strict_types= 1 );
44
55namespace App \Providers ;
66
77use Illuminate \Database \Eloquent \Model ;
88use Illuminate \Support \ServiceProvider ;
9+ use Opcodes \LogViewer \Facades \LogViewer ;
910
1011class AppServiceProvider extends ServiceProvider
1112{
@@ -34,4 +35,11 @@ public function boot(): void
3435 // Make sure that all properties being called exists in the model
3536 Model::shouldBeStrict ();
3637 }
38+
39+ private function setLogViewer (): void
40+ {
41+ LogViewer::auth (function ($ request ) {
42+ return $ request ->user () && $ request ->user ()->is_admin ;
43+ });
44+ }
3745}
Original file line number Diff line number Diff line change 3939 |
4040 */
4141
42- 'route_path ' => 'log-viewer ' ,
42+ 'route_path ' => 'logs ' ,
4343
4444 /*
4545 |--------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public function up(): void
1515 {
1616 Schema::create ('users ' , function (Blueprint $ table ): void {
1717 $ table ->id ();
18+ $ table ->boolean ('is_admin ' )->default (false );
1819 $ table ->string ('name ' );
1920 $ table ->string ('email ' )->unique ();
2021 $ table ->timestamp ('email_verified_at ' )->nullable ();
Original file line number Diff line number Diff line change 11<?php
22
3- declare (strict_types = 1 );
3+ declare (strict_types= 1 );
44
55namespace Database \Seeders ;
66
@@ -20,6 +20,14 @@ public function run(): void
2020 User::factory ()->create ([
2121 'name ' => 'Test User ' ,
2222 'email ' => 'test@example.com ' ,
23+ 'is_admin ' => true ,
24+ 'password ' => bcrypt ('password ' ),
25+ ]);
26+
27+ User::factory ()->create ([
28+ 'name ' => 'Test User 1 ' ,
29+ 'email ' => 'test1@example.com ' ,
30+ 'is_admin ' => false ,
2331 ]);
2432
2533 $ this ->call ([
You can’t perform that action at this time.
0 commit comments