Configuration
- How to Manage Configuration
- Disable/Enable Module
- RTL Mode
- Changing Language
- User Model
- Authentication Guard
- Unauthorized Redirect Path
- Routes Prefix
- Additional Middlewares
- Pagination Count
- Lazy Updating
- Change Auth Strategy
- Admin Provider Class
How to Manage Configuration
When you run panel:install
command, it will publish the config file in config/easy_panel.php
path, and You can manage it easily.
Disable/Enable Module
It's possible to disable or enable the whole module easily by just changing the enable
key in the config file.
return [ ... 'enable' => true, ... ];
When you set enable
as false
the routes won't be registered anymore, and you can't access the routes to manage your Admin Panel!
RTL Mode
If you want to change your style from LTR to RTL You can change the value of rtl_mode
in configs:
return [ ... 'rtl_mode' => true, ... ];
Changing Language
EasyPanel is fully translatable, to manage the values and texts, You can copy the resources/lang/en_panel.json
file and customize the texts.
For example, if You want to add a france
language to EasyPanel, You have to create a copy from resources/lang/en_panel.json
into resources/lang/fr_panel.json
, now You can set the value of lang
to fr
.
Don't need to pass the full name of the file, just pass the prefix before _panel.json
The pattern is: *_panel.json
:
- fa_panel.json => fa
- en_panel.json => en
- chinese_panel.json => chinese
return [ ... 'lang' => 'chinese', ... ];
User Model
EasyPanel to manage admins uses the default User
Model, if You want to change it, You can pass the new model into user_model
config key.
return [ ... 'user_model' => \App\Models\Admin::class, ... ];
Authentication Guard
By default, EasyPanel uses the web
guard to identify the logged-in user.
If you have customized this, or You need to change the guard for authentication, You have to change auth_guard
in config:
return [ ... 'auth_guard' => 'admin', ... ];
Unauthorized Redirect Path
If an unauthorized user tries to access the EasyPanel routes, it will be redirected to a path, and this path can be changed in the config file with redirect_unauthorized
key.
return [ ... 'redirect_unauthorized' => '/', ... ];
Routes Prefix
In default, EasyPanel uses /admin
prefix, and You can access the routes by: localhost:8000/admin
.
As you may guess, It's fully customizable in the config file:
return [ ... 'route_prefix' => 'panel', // localhost:8000/panel ... ];
Additional Middlewares
If you need to add more middlewares to EasyPanel routes, you can pass them in config as an array:
return [ ... 'additional_middlewares' => ['AdminHasApproved', 'UserIsNotBlocked'] ... ];
Pagination Count
The Read page has pagination, and You can customize the count of pagination in the config.
The default is 20, and You can change it:
return [ ... 'pagination_count' => 30, ... ];
Lazy Updating
The lazy mode uses wire:model.lazy
in searching strategy, and inputs instead of wire:model
.
Read more about lazy updating.
return [ ... 'lazy_mode' => true, ... ];
It will accept a boolean value.
Change Auth Strategy
Admin Identifier class uses a Facade, and You can change the base class very easily.
For example, if You want to change the strategy of identifying administrators, You can create a class with a public check($id)
method:
namespace App\Services\Auth; class AdminIdentifier { public function check($id){ return \App\Models\Admin::where('user_id', $id)->exists(); } }
Now You can pass the new namespace into the config with auth_class
key:
return [ ... 'auth_class' => App\Services\Auth\AdminIdentifier::class, ... ];
Admin Provider Class
Admin Provider class also uses a Facade, and You can swap the class.
If you need to customize the way of creating an administrator, delete an administrator or administrator list, You have to create a custom class and change the value of admin_provider_class
to the new class.
This class must have 4 methods called:
makeAdmin($id, $isSuper = true): array
getAdmins(): array|collection
findUser(): Model
deleteAdmin(): void
namespace App\Services; class AdminProvider { public function makeAdmin($id, $isSuper = true){ try{ \App\Models\Admin::create(['user_id' => $id, 'super_user' => $isSuper]); return [ 'type' => 'success', 'message' => 'Admin created!' ]; } catch(\Exception $exception){ return [ 'type' => 'error', 'message' => $exception->getMessage() ]; } } public function getAdmins(){ return \App\Models\User::whereHas('admin')->get(); } public function findUser($id){ return \App\Models\User::findOrFail($id); } public function deleteAdmin($id){ \App\Models\Admin::where('user_id', $id)->delete(); } }
Now You can pass the new namespace into the config with admin_provider_class
key:
return [ ... 'admin_provider_class' => App\Services\AdminProvider::class, ... ];