it's a basic Management panel for laravel application
mohamadtsn/laravel-supernova is a Laravel package for it's a basic management panel for laravel application.
It currently has 1 GitHub stars and 325 downloads on Packagist (latest version 3.1.0).
Install it with composer require mohamadtsn/laravel-supernova.
Discover more Laravel packages by mohamadtsn
or browse all Laravel packages to compare alternatives.
Last updated
composer require mohamadtsn/laravel-supernova
Publishing Base Vendor Files
php artisan supernova:publish [tags] --force
Publishing Custom Vendor File
php artisan supernova:publish [tags] --force
Change locale to fa in config/app.php
'locale' => 'fa',
Put this in App\Models\User.php
use Mohamadtsn\Supernova\Models\User as SupernovaUser; // use supernova User Model
use Mohamadtsn\Supernova\Classes\Traits\PermissionWrapper;
class User extends SupernovaUser
{
use HasApiTokens, HasFactory, Notifiable, PermissionWrapper;
// other class methods
}
Add level to fillable fields in App\Models\User.php.
protected $fillable = [
'level',
];
Add these seeders call in Database\Seeders\DatabaseSeeder.php in run() method:
class DatabaseSeeder extends Seeder
{
public function run()
{
// Other seeders call
// You add seeders
$this->call(UserSeeder::class); // #1
$this->call(PermissionSeeder::class); // #2
}
}
Add these into guards section in config/auth.php:
'guards' => [
// other guard
'admin' => [
'driver' => 'session',
'provider' => 'users',
],
],
Put these in app/Http/Kernel.php like below:
use App\Http\Middleware\Panel\CheckPermission; // use Middleware class CheckPermission
class Kernel extends HttpKernel
{
protected $routeMiddleware = [
// other routeMiddleware
'permission' => CheckPermission::class, // add CheckPermission::class on this section
];
}
Change these in App/Http/Middleware/Authenticate.php in redirectTo method like below:
protected function redirectTo($request)
{
if ($request->expectsJson()) {
return response()->json([
'title' => 'access denied',
'text' => 'unauthorized ...!',
'type' => 'error'
], Response::HTTP_FORBIDDEN);
}
return route('panel.login');
}
add admin panel routes file routes/admin.php to App/Providers/RouteServiceProvider.php in boot() method
IMPORTANT!! Be sure to add before `web.php`.
Look carefully:public function boot()
{
$this->routes(function () {
// other routes file
Route::middleware('web')
->namespace($this->namespace)
->domain(config('supernova.management_url'))
->group(base_path('routes/admin.php')); // #1 add admin panel routes (admin.php)
Route::middleware('web')
->namespace($this->namespace)
->domain(config('app.url'))
->group(base_path('routes/web.php')); // #2 web.php routes
});
}
php artisan serve):public function boot()
{
$this->routes(function () {
// other routes file
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/admin.php')); // #1 add admin panel routes (admin.php)
Route::middleware('web')
->namespace($this->namespace)
->domain(config('app.url'))
->group(base_path('routes/web.php')); // #2 web.php routes
});
}
.env filephp artisan migrate:fresh --seed // "Associated with" Drop All Tables & Migrate and seeding
"Or"
php artisan migrate --seed // "Without" Drop All Tables & Migrate and seeding
composer dump-autoload
Build a virtual subdomain with name Management
example.test // Main URLmanagement.example.test // Admin Panel URLadd param Admin Panel URL to env file with name APP_MANAGEMENT_URL like below:
APP_URL= http://shop.test
APP_MANAGEMENT_URL= http://management.shop.test
add config Admin Panel URL to config/supernova.php file with name management_url like below:
return [
// other configs
'management_url' => env('APP_MANAGEMENT_URL', 'http://management.example.test'),
]
Login to Panel management.example.test/login
Dashboard Panel management.example.test/
php artisan supernova:publish supernova-basic-routes --force
php artisan serve
Supernova Panel Routes only with Prefix panel127.0.0.1:8000/panel/login[email protected]supernova@123Enjoy it :wave: