simaocoutinho / admin
Admin Dashboard Powered By AdminLTE
Installs: 66
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:CSS
README
Instalation
Install Jetstream
Follow link: https://jetstream.laravel.com/2.x/installation.html
Install LaravelDebugbar
composer require barryvdh/laravel-debugbar --dev
Install AdminStarterCode
composer require simaocoutinho/admin
Publish Public Assets
Assets that will change according the project
php artisan vendor:publish --tag="admin-public"
Publish Views
php artisan vendor:publish --tag="admin-views" --force
In file: config/filesystem.php
Replace:
'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ],
by:
'public' => [ 'driver' => 'local', 'root' => public_path('uploads'), 'url' => env('APP_URL').'/uploads', 'visibility' => 'public', ],
Debug Only for developer
In file: config/app.php
Replace:
'debug' => (bool) env('APP_DEBUG', false),
by:
'debug' => value(function() { if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == 'IP') return true; return false; }),
Override Redirect on PageExpired
In file: app/Exceptions/Handler.php
Add:
public function register() { ... $this->renderable(function (\Exception $e) { if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) { return redirect()->route('login'); }; }); }
Override Login & Register Redirect
Link: https://laravel-news.com/override-login-redirects-in-jetstream-fortify
Create: app/Http/Responses/LoginResponse.class
Copy:
namespace App\Http\Responses; use Auth; use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract; class LoginResponse implements LoginResponseContract { /** * @param $request * @return mixed */ public function toResponse($request) { if (Auth::user()->type == 'client') { return redirect()->route('home'); } else { return redirect()->route('dashboard'); } } }
Create: app/Http/Responses/RegisterResponse.class
Copy:
namespace App\Http\Responses; use Auth; use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract; class RegisterResponse implements RegisterResponseContract { public function toResponse($request) { if (Auth::user()->type == 'client') { return redirect()->route('home'); } else { return redirect()->route('dashboard'); } } }
In file: FortifyServiceProvider.class
Add:
use App\Http\Responses\LoginResponse; use App\Http\Responses\RegisterResponse; use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract; use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract; use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract; public function boot() { // ... $this->app->singleton(LoginResponseContract::class, LoginResponse::class); $this->app->singleton(RegisterResponseContract::class, RegisterResponse::class); $this->app->singleton(TwoFactorLoginResponseContract::class, LoginResponse::class); }
Check if user is active on login
In file: app/Providers/JetstreamServiceProvider.php
Add:
public function boot() { ... // Verifica se o user está ativo Fortify::authenticateUsing(function (Request $request) { $user = User::where('email', $request->email)->first(); if ($user && Hash::check($request->password, $user->password)) { if ($user->state == 1) { return $user; } } return null; }); }
Force HTTPS via htaccess
# Force HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]