Have you ever tried to build a complete admin panel in Laravel from zero?
It takes lots of energy and time and, you may not like what you have built.
I had the same problem as you, When I was trying to make an admin panel and I think to myself and I said: Reza there are lots of people who want to build a beautiful admin panel like you, make your module more flexible and share It in Github.
Wow, It's very good I should do it for the open-source community.
So I decided to build an admin panel module and because I love Livewire I decided to do that with Livewire.
If You don't know what is Livewire I should tell You It is a Fullstack framework and makes You needless from Javascript frameworks.
Come on dude, don't say too much show us your package...
Ok, let me tell you about EasyPanel.
EasyPanel is an admin panel package for Laravel and You can build your admin panel in 2 minutes (maybe less than 2 minutes).
There are some features of EasyPanel :
- Create CRUD in the config file.
- Manage route prefix and addresses
- Beautiful UI/UX with AdminMart template
- Add/remove Admins with command line
- Every UserProviders and Authentication classes are customizable and you can change them
- You can create your own routes and customize our views and components
- Manage pagination count
- Multi lang
- Real-time validation with Livewire
- Customize every action in your project
- A small and beautiful TODO (You can disable it in your config)
- Create a nice and responsive view based on your data in the config file for every CRUDs
- Custom validation based on the config file
- Ajax search with Livewire in every column you want
So We saw the features, But let's build an admin with articles section (Create, Read, Update, Delete)
first of all, We must install the package (how 🤔)
Don't be afraid It's very easy as the package name.
Install the package with Composer.
composer require rezaamini-ir/laravel-easypanel
next, We should publish configurations and styles (Just with one command) :
php artisan panel:install
Congratulations 👏! You have installed the package.
Now We have access to the config file in config
directory and we can pass our cruds to actions
key in the easy_panel.php
file.
To create a CRUD we must pass 3 steps:
1- Create a CRUD config file.
To create a CRUD config we must run this command out:
php artisan panel:config Article
which Article is our model name.
the file will be created in resources/cruds/article.php
2- Config our CRUD file and pass the data that we want.
let's write our array in the CRUD file :
return [
'model' => \App\Models\Article::class,
// searchable field, if you dont want search feature, remove it
'search' => ['title', ['user' => 'name']],
// Manage actions in crud
'create' => true,
'update' => true,
'delete' => true,
// Validation in update and create actions
'validation' => [
'title' => 'required',
'content' => 'required|min:30',
],
// Write every fields in your db which you want to show
'fields' => [
'title' => 'text',
'content' => 'textarea',
'image' => 'file'
],
'store' => [
'image' => 'image/articles'
],
//Default that data you want to pass in create and update actions, Do not you want? Delete this key.
'extra_values' => [
'user_id' => 'auth()->user()->id'
],
// which kind of data should be showed in list page
'show' => ['title', 'image', ['user' => 'name']],
];
Now we must pass 'article' value in our config file in config/easy_panel.php
in actions
key like:
'actions' => ['article', 'user']
3- Run CRUD creator command:
with one command We can create our CRUD action with routes and everything which a panel needs...
php artisan panel:crud article
Now we have an admin panel with an Article section and a default TODO list.
So easy 😁.
This is a simple example of this package and you can customize every file in your project.
Repository address :
https://github.com/rezaamini-ir/laravel-easypanel
Don't forget to star to the package ⭐.
You are free to submit a pull request :)
Top comments (19)
Hi. thanks for the lovely admin panel. I'm new to laravel and setup your admin panel on one of my volunteer projects at buildlk.com
there was a question about how to edit the list views but found the solution. The partial blade views were a little mystery :) Thanks the admin dashboard is awesome.
When you try to update the crud config file you have to rerun
php artisan panel:crud -f
with -f flag to recreate the files.How about role and permission ?
We will implement role and permission in new versions!
127.0.0.1:8000/admin 404 not found error
ups i stayed at step 1:
$ php artisan panel:config article -m Article
The "-m" option does not exist.
Thanks!
It was edited, in the new version, you don't need to pass -m flag and you have to pass your model name directly.
How to overwrite crud?
What do you mean by "overwriting CRUD"?
How to use a select field from the configuration file?
Hey,
You have to use this syntax :
I think that you forgot to create the model and migration for articles ...
Article in this project is just an example
We are not going to create an article section
What is the route for accessing the panel?
The default route is '/admin' but you can change it in the config file
Why?
PS C:\laragon\www\easyPanel> php artisan panel:config article -m=Article
'article' must be equal to model name
php artisan panel:config Article
Use this format.
Hey,
Thanks for the admin panel. But the thing is how can I authenticate? I've installed laravel ui. Should it work?
You have to authenticate user in your project without this panel's feature!
It will check if the
is_superuser
or anything which has been set in config for logged in user is true then it lets users access to panel.