This week I learnt about Laravel backpack. We have been creating a lot of sites that need Admin CRUD (Create, Read, Update and Delete) functionalities. As a Developer we are always looking for ways to make our coding more stream lined and effective.
Laravel backpack is a framework that helps you set up and build Admin panels a lot quicker.
Once you have installed Laravel Backpack. All you need to do is:
- Create a migration table using the line:
php artisan make:migration create_users_table -- model=0 --schema="name:string, email:string:unique"
- Then migrate your table onto your Database:
php artisan migrate
- Then by using
php artisan backpack:crud user, this will create a simple CRUD panel. This generates the following:
- a request file, for form validation (app\Http\Requests\UserCrudRequest.php)
- a controller file (app\Http\Controllers\Admin\UserCrudController)
- a route, inside routes\backpack\custom.php pointing to the controller
- a sidebar item inside resources\views\vendor\backpack\base\inc\sidebar_content.blade.php, this can be used to display your Admin CRUD side panel
Once you have done this, you are set to start customizing your Admin panel for your specific needs.