Skip to content

Commit

Permalink
Merge pull request #28 from dcblogdev/v4
Browse files Browse the repository at this point in the history
V4
  • Loading branch information
dcblogdev authored Aug 25, 2023
2 parents 79600e4 + fbfb8af commit d5f16b8
Show file tree
Hide file tree
Showing 94 changed files with 699 additions and 383 deletions.
3 changes: 2 additions & 1 deletion stubs/app/Console/Commands/ClearLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
class ClearLog extends Command
{
protected $signature = 'log:clear';

protected $description = 'empty error log';

public function handle()
{
if (file_exists(storage_path('logs/laravel.log'))) {
$f = fopen(storage_path('logs/laravel.log'), "r+");
$f = fopen(storage_path('logs/laravel.log'), 'r+');
if ($f !== false) {
ftruncate($f, 0);
fclose($f);
Expand Down
20 changes: 3 additions & 17 deletions stubs/app/Console/Commands/MakeDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,18 @@

class MakeDatabaseCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'db:build';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Build and seed all table from fresh.';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
public function handle(): void
{
if (app()->environment(['local', 'staging'])) {
if (in_array(config('app.env'), ['local', 'staging'])) {
if ($this->confirm('Do you wish to continue?')) {
$this->call('migrate:fresh');
$this->line('------');
$this->call('db:seed');
$this->line('Completed!');
}
} else {
$this->error('This command is disabled on production.');
Expand Down
1 change: 0 additions & 1 deletion stubs/app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
30 changes: 30 additions & 0 deletions stubs/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

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

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

if ($request->user()->hasRole('user')) {
return redirect(route('admin.users.index'));
}

return redirect()->intended(route('dashboard'));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 1 addition & 1 deletion stubs/app/Http/Controllers/Auth/JoinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\AuditTrail;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Routing\Redirector;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;
Expand Down
4 changes: 3 additions & 1 deletion stubs/app/Http/Controllers/Auth/NewPasswordController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down Expand Up @@ -56,6 +58,6 @@ function ($user) use ($request) {
return $status == Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
->withErrors(['email' => __($status)]);
}
}
2 changes: 2 additions & 0 deletions stubs/app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down Expand Up @@ -39,6 +41,6 @@ public function store(Request $request): RedirectResponse
return $status == Password::RESET_LINK_SENT
? back()->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
->withErrors(['email' => __($status)]);
}
}
3 changes: 2 additions & 1 deletion stubs/app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
Expand Down
2 changes: 2 additions & 0 deletions stubs/app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 2 additions & 0 deletions stubs/app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
Expand Down
2 changes: 2 additions & 0 deletions stubs/app/Http/Controllers/WelcomeController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use Illuminate\View\View;
Expand Down
1 change: 0 additions & 1 deletion stubs/app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Middleware;

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

declare(strict_types=1);

namespace App\Http\Livewire\Admin;
namespace App\Livewire\Admin;

use function abort_if_cannot;
use App\Models\AuditTrail;
use App\Models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Carbon;
use Livewire\Attributes\Title;
use Livewire\Component;
use Livewire\WithPagination;

use function abort_if_cannot;
use function view;

#[Title('Audit Trails')]
class AuditTrails extends Component
{
use WithPagination;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

namespace App\Http\Livewire\Admin;
namespace App\Livewire\Admin;

use Livewire\Attributes\Title;
use Livewire\Component;

#[Title('Dashboard')]
class Dashboard extends Component
{
public function render()
{
abort_unless(auth()->user()->can('view_dashboard'), 403);
abort_if_cannot('view_dashboard');

return view('livewire.admin.dashboard');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

declare(strict_types=1);

namespace App\Http\Livewire\Admin;
namespace App\Livewire\Admin;

use Illuminate\Contracts\View\View;
use Livewire\Component;

use function view;

class HelpMenu extends Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

declare(strict_types=1);

namespace App\Http\Livewire\Admin;
namespace App\Livewire\Admin;

use App\Models\Notification;
use function auth;
use Illuminate\Contracts\View\View;
use Livewire\Component;

use function auth;
use function now;
use function view;

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

public function mount(): void
{
parent::mount();

$this->notifications = Notification::where('assigned_to_user_id', auth()->id())->take(20)->get();
$this->unseenCount = Notification::where('assigned_to_user_id', auth()->id())->where('viewed', 0)->count();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

declare(strict_types=1);

namespace App\Http\Livewire\Admin\Roles;
namespace App\Livewire\Admin\Roles;

use App\Models\Role;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\Validation\ValidationException;
use Livewire\Component;
use Livewire\WithPagination;

class Create extends Component
{
use WithPagination;

public $role = '';

protected array $rules = [
Expand Down Expand Up @@ -63,6 +66,6 @@ public function store(): Redirector|RedirectResponse
public function cancel(): void
{
$this->reset();
$this->dispatchBrowserEvent('close-modal');
$this->dispatch('close-modal');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@

declare(strict_types=1);

namespace App\Http\Livewire\Admin\Roles;
namespace App\Livewire\Admin\Roles;

use function add_user_log;
use App\Models\Permission;
use App\Models\Role;
use function flash;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Title;
use Livewire\Component;
use function redirect;
use function view;

#[Title('Edit Role')]
class Edit extends Component
{
public ?Role $role = null;
public Role $role;

public $label = '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

declare(strict_types=1);

namespace App\Http\Livewire\Admin\Roles;
namespace App\Livewire\Admin\Roles;

use App\Models\Role;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\Title;
use Livewire\Component;
use Livewire\WithPagination;
use function view;

#[Title('Roles')]
class Roles extends Component
{
use WithPagination;
Expand Down Expand Up @@ -60,6 +61,6 @@ public function deleteRole($id): void
{
$this->builder()->findOrFail($id)->delete();

$this->dispatchBrowserEvent('close-modal');
$this->dispatch('close-modal');
}
}
Loading

0 comments on commit d5f16b8

Please sign in to comment.