Skip to content

Commit 599dba1

Browse files
author
kreaweb.be
committed
Installation
1 parent d6d6283 commit 599dba1

File tree

9 files changed

+487
-398
lines changed

9 files changed

+487
-398
lines changed

app/Providers/AppServiceProvider.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
use App\Models\Userlog;
66
use Illuminate\Database\Eloquent\Model;
77
use Illuminate\Database\QueryException;
8+
use Illuminate\Foundation\Console\AboutCommand;
89
use Illuminate\Pagination\Paginator;
910
use Illuminate\Support\Facades\DB;
1011
use Illuminate\Support\Facades\Event;
1112
use Illuminate\Support\Facades\Gate;
1213
use Illuminate\Support\Facades\Log;
1314
use Illuminate\Support\ServiceProvider;
1415
use Illuminate\Support\Str;
16+
use Opcodes\LogViewer\Facades\LogViewer;
1517
use Stevebauman\Location\Facades\Location;
1618

1719
class AppServiceProvider extends ServiceProvider
@@ -29,31 +31,60 @@ public function register(): void
2931
*/
3032
public function boot(): void
3133
{
34+
// -----------------------------------------------------------------------
35+
// Pagination
36+
// -----------------------------------------------------------------------
3237
Paginator::useBootstrapFive();
3338

39+
// -----------------------------------------------------------------------
3440
// log all queries when in not in production
41+
// -----------------------------------------------------------------------
3542
if (! app()->isProduction()) {
3643
DB::listen(function ($query) {
3744
logger(Str::replaceArray('?', $query->bindings, $query->sql));
3845
});
3946
}
40-
47+
// -----------------------------------------------------------------------
4148
// log all N+1 queries
49+
// -----------------------------------------------------------------------
4250
Model::preventLazyLoading();
4351

4452
Model::handleLazyLoadingViolationUsing(function ($model, $relation) {
4553
Log::warning("N+1 Query detected.\r\n" . sprintf('N+1 Query detected in model %s on relation %s.', get_class($model), $relation));
4654
});
4755

56+
// -----------------------------------------------------------------------
57+
// Developer only
58+
// -----------------------------------------------------------------------
4859
Gate::define('developer', function ($user) {
4960
return $user->is_developer;
5061
});
5162

63+
// -----------------------------------------------------------------------
64+
// Log Viewer : grant access (in production) to developer
65+
// -----------------------------------------------------------------------
66+
LogViewer::auth(function ($request) {
67+
return auth()->user() && auth()->user()->is_developer;
68+
});
69+
70+
// -----------------------------------------------------------------------
71+
// Init application
72+
// -----------------------------------------------------------------------
5273
Event::listen(\Illuminate\Auth\Events\Login::class, function ($event) {
5374
$this->setYear();
5475

5576
$this->logUser($event->user);
5677
});
78+
79+
// -----------------------------------------------------------------------
80+
// about
81+
// -----------------------------------------------------------------------
82+
AboutCommand::add('Application', [
83+
'Name' => 'L11 - BS 5 - DT 2',
84+
'author' => 'kreaweb.be',
85+
'github' => 'https://github.com/MGeurts/laravel-11-bootstrap-5-datatables',
86+
'license' => 'MIT License',
87+
]);
5788
}
5889

5990
private function setYear()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"license": "MIT",
77
"require": {
88
"php": "^8.2",
9-
"arcanedev/log-viewer": "^11.0",
109
"khill/lavacharts": "3.1.*",
1110
"laravel/framework": "^11.0",
1211
"laravel/tinker": "^2.9",
12+
"opcodesio/log-viewer": "^3.8",
1313
"spatie/laravel-backup": "^8.6",
1414
"stevebauman/location": "^7.2",
1515
"yajra/laravel-datatables-oracle": "^11.0"

0 commit comments

Comments
 (0)