Skip to content

Commit 0b7419a

Browse files
implements log viewer package
1 parent 0aeb2d9 commit 0b7419a

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

app/Http/Controllers/Settings/ProfileController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Http\RedirectResponse;
1111
use Illuminate\Http\Request;
1212
use Illuminate\Support\Facades\Auth;
13+
use Illuminate\Support\Facades\Log;
1314
use Inertia\Inertia;
1415
use Inertia\Response;
1516

app/Models/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
}

app/Providers/AppServiceProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace App\Providers;
66

77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Support\ServiceProvider;
9+
use Opcodes\LogViewer\Facades\LogViewer;
910

1011
class 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
}

config/log-viewer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
|
4040
*/
4141

42-
'route_path' => 'log-viewer',
42+
'route_path' => 'logs',
4343

4444
/*
4545
|--------------------------------------------------------------------------

database/migrations/0001_01_01_000000_create_users_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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();

database/seeders/DatabaseSeeder.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace 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([

0 commit comments

Comments
 (0)