Skip to content

Commit d5f16b8

Browse files
authored
Merge pull request #28 from dcblogdev/v4
V4
2 parents 79600e4 + fbfb8af commit d5f16b8

File tree

94 files changed

+699
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+699
-383
lines changed

stubs/app/Console/Commands/ClearLog.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
class ClearLog extends Command
88
{
99
protected $signature = 'log:clear';
10+
1011
protected $description = 'empty error log';
1112

1213
public function handle()
1314
{
1415
if (file_exists(storage_path('logs/laravel.log'))) {
15-
$f = fopen(storage_path('logs/laravel.log'), "r+");
16+
$f = fopen(storage_path('logs/laravel.log'), 'r+');
1617
if ($f !== false) {
1718
ftruncate($f, 0);
1819
fclose($f);

stubs/app/Console/Commands/MakeDatabaseCommand.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,18 @@
66

77
class MakeDatabaseCommand extends Command
88
{
9-
/**
10-
* The name and signature of the console command.
11-
*
12-
* @var string
13-
*/
149
protected $signature = 'db:build';
1510

16-
/**
17-
* The console command description.
18-
*
19-
* @var string
20-
*/
2111
protected $description = 'Build and seed all table from fresh.';
2212

23-
/**
24-
* Execute the console command.
25-
*
26-
* @return mixed
27-
*/
28-
public function handle()
13+
public function handle(): void
2914
{
30-
if (app()->environment(['local', 'staging'])) {
15+
if (in_array(config('app.env'), ['local', 'staging'])) {
3116
if ($this->confirm('Do you wish to continue?')) {
3217
$this->call('migrate:fresh');
3318
$this->line('------');
3419
$this->call('db:seed');
20+
$this->line('Completed!');
3521
}
3622
} else {
3723
$this->error('This command is disabled on production.');

stubs/app/Console/Kernel.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
1919
/**
2020
* Define the application's command schedule.
2121
*
22-
* @param \Illuminate\Console\Scheduling\Schedule $schedule
2322
* @return void
2423
*/
2524
protected function schedule(Schedule $schedule)

stubs/app/Exceptions/Handler.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* The list of the inputs that are never flashed to the session on validation exceptions.
12+
*
13+
* @var array<int, string>
14+
*/
15+
protected $dontFlash = [
16+
'current_password',
17+
'password',
18+
'password_confirmation',
19+
];
20+
21+
/**
22+
* Register the exception handling callbacks for the application.
23+
*/
24+
public function register(): void
25+
{
26+
$this->reportable(function (Throwable $e) {
27+
//
28+
});
29+
}
30+
}

stubs/app/Http/Controllers/Auth/AuthenticatedSessionController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;
@@ -28,6 +30,10 @@ public function store(LoginRequest $request): RedirectResponse
2830

2931
$request->session()->regenerate();
3032

33+
if ($request->user()->hasRole('user')) {
34+
return redirect(route('admin.users.index'));
35+
}
36+
3137
return redirect()->intended(route('dashboard'));
3238
}
3339

stubs/app/Http/Controllers/Auth/ConfirmablePasswordController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;

stubs/app/Http/Controllers/Auth/EmailVerificationNotificationController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;

stubs/app/Http/Controllers/Auth/EmailVerificationPromptController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;

stubs/app/Http/Controllers/Auth/JoinController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace App\Http\Controllers\Auth;
66

7+
use App\Http\Controllers\Controller;
78
use App\Models\AuditTrail;
89
use App\Models\Setting;
910
use App\Models\User;
1011
use Illuminate\Contracts\View\View;
1112
use Illuminate\Http\RedirectResponse;
1213
use Illuminate\Http\Request;
13-
use Illuminate\Routing\Controller;
1414
use Illuminate\Routing\Redirector;
1515
use Illuminate\Support\Facades\Hash;
1616
use Illuminate\Validation\Rules\Password;

stubs/app/Http/Controllers/Auth/NewPasswordController.php

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

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;
@@ -56,6 +58,6 @@ function ($user) use ($request) {
5658
return $status == Password::PASSWORD_RESET
5759
? redirect()->route('login')->with('status', __($status))
5860
: back()->withInput($request->only('email'))
59-
->withErrors(['email' => __($status)]);
61+
->withErrors(['email' => __($status)]);
6062
}
6163
}

stubs/app/Http/Controllers/Auth/PasswordController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;

stubs/app/Http/Controllers/Auth/PasswordResetLinkController.php

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

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;
@@ -39,6 +41,6 @@ public function store(Request $request): RedirectResponse
3941
return $status == Password::RESET_LINK_SENT
4042
? back()->with('status', __($status))
4143
: back()->withInput($request->only('email'))
42-
->withErrors(['email' => __($status)]);
44+
->withErrors(['email' => __($status)]);
4345
}
4446
}

stubs/app/Http/Controllers/Auth/RegisteredUserController.php

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

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;
68
use App\Models\User;
7-
use Illuminate\Auth\Events\Registered;
89
use Illuminate\Http\RedirectResponse;
910
use Illuminate\Http\Request;
1011
use Illuminate\Support\Str;

stubs/app/Http/Controllers/Auth/VerifyEmailController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;

stubs/app/Http/Controllers/Controller.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers;
46

57
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

stubs/app/Http/Controllers/WelcomeController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers;
46

57
use Illuminate\View\View;

stubs/app/Http/Middleware/RedirectIfAuthenticated.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Http\Middleware;
44

5-
use App\Providers\RouteServiceProvider;
65
use Closure;
76
use Illuminate\Http\Request;
87
use Illuminate\Support\Facades\Auth;

stubs/app/Http/Livewire/Admin/AuditTrails.php renamed to stubs/app/Livewire/Admin/AuditTrails.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Livewire\Admin;
5+
namespace App\Livewire\Admin;
66

7-
use function abort_if_cannot;
87
use App\Models\AuditTrail;
98
use App\Models\User;
109
use Illuminate\Contracts\View\View;
1110
use Illuminate\Support\Carbon;
11+
use Livewire\Attributes\Title;
1212
use Livewire\Component;
1313
use Livewire\WithPagination;
14+
15+
use function abort_if_cannot;
1416
use function view;
1517

18+
#[Title('Audit Trails')]
1619
class AuditTrails extends Component
1720
{
1821
use WithPagination;

stubs/app/Http/Livewire/Admin/Dashboard.php renamed to stubs/app/Livewire/Admin/Dashboard.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22

3-
namespace App\Http\Livewire\Admin;
3+
namespace App\Livewire\Admin;
44

5+
use Livewire\Attributes\Title;
56
use Livewire\Component;
67

8+
#[Title('Dashboard')]
79
class Dashboard extends Component
810
{
911
public function render()
1012
{
11-
abort_unless(auth()->user()->can('view_dashboard'), 403);
13+
abort_if_cannot('view_dashboard');
1214

1315
return view('livewire.admin.dashboard');
1416
}

stubs/app/Http/Livewire/Admin/HelpMenu.php renamed to stubs/app/Livewire/Admin/HelpMenu.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Livewire\Admin;
5+
namespace App\Livewire\Admin;
66

77
use Illuminate\Contracts\View\View;
88
use Livewire\Component;
9+
910
use function view;
1011

1112
class HelpMenu extends Component

stubs/app/Http/Livewire/Admin/NotificationsMenu.php renamed to stubs/app/Livewire/Admin/NotificationsMenu.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Livewire\Admin;
5+
namespace App\Livewire\Admin;
66

77
use App\Models\Notification;
8-
use function auth;
98
use Illuminate\Contracts\View\View;
109
use Livewire\Component;
10+
11+
use function auth;
1112
use function now;
1213
use function view;
1314

@@ -19,8 +20,6 @@ class NotificationsMenu extends Component
1920

2021
public function mount(): void
2122
{
22-
parent::mount();
23-
2423
$this->notifications = Notification::where('assigned_to_user_id', auth()->id())->take(20)->get();
2524
$this->unseenCount = Notification::where('assigned_to_user_id', auth()->id())->where('viewed', 0)->count();
2625
}

stubs/app/Http/Livewire/Admin/Roles/Create.php renamed to stubs/app/Livewire/Admin/Roles/Create.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Livewire\Admin\Roles;
5+
namespace App\Livewire\Admin\Roles;
66

77
use App\Models\Role;
88
use Illuminate\Contracts\View\View;
99
use Illuminate\Http\RedirectResponse;
1010
use Illuminate\Routing\Redirector;
1111
use Illuminate\Validation\ValidationException;
1212
use Livewire\Component;
13+
use Livewire\WithPagination;
1314

1415
class Create extends Component
1516
{
17+
use WithPagination;
18+
1619
public $role = '';
1720

1821
protected array $rules = [
@@ -63,6 +66,6 @@ public function store(): Redirector|RedirectResponse
6366
public function cancel(): void
6467
{
6568
$this->reset();
66-
$this->dispatchBrowserEvent('close-modal');
69+
$this->dispatch('close-modal');
6770
}
6871
}

stubs/app/Http/Livewire/Admin/Roles/Edit.php renamed to stubs/app/Livewire/Admin/Roles/Edit.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Livewire\Admin\Roles;
5+
namespace App\Livewire\Admin\Roles;
66

7-
use function add_user_log;
87
use App\Models\Permission;
98
use App\Models\Role;
10-
use function flash;
119
use Illuminate\Contracts\View\View;
1210
use Illuminate\Http\RedirectResponse;
1311
use Illuminate\Routing\Redirector;
1412
use Illuminate\Validation\ValidationException;
13+
use Livewire\Attributes\Title;
1514
use Livewire\Component;
16-
use function redirect;
17-
use function view;
1815

16+
#[Title('Edit Role')]
1917
class Edit extends Component
2018
{
21-
public ?Role $role = null;
19+
public Role $role;
2220

2321
public $label = '';
2422

stubs/app/Http/Livewire/Admin/Roles/Roles.php renamed to stubs/app/Livewire/Admin/Roles/Roles.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Livewire\Admin\Roles;
5+
namespace App\Livewire\Admin\Roles;
66

77
use App\Models\Role;
88
use Illuminate\Contracts\View\View;
9+
use Livewire\Attributes\Title;
910
use Livewire\Component;
1011
use Livewire\WithPagination;
11-
use function view;
1212

13+
#[Title('Roles')]
1314
class Roles extends Component
1415
{
1516
use WithPagination;
@@ -60,6 +61,6 @@ public function deleteRole($id): void
6061
{
6162
$this->builder()->findOrFail($id)->delete();
6263

63-
$this->dispatchBrowserEvent('close-modal');
64+
$this->dispatch('close-modal');
6465
}
6566
}

0 commit comments

Comments
 (0)