Laravel, CRUD – Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom
I have made few weeks ago an article about an existing Laravel Admin Panel Generator named Navigator. It was basically a time-saver for a dashboard’s POC. I have discovered a very useful and practical tool but the choice was quite arbitrary. Fist of all, it was the first tool on the list that I have consulted in the article of of Povilas Korop. Second, I was also seduced by the care given to the design aspects and the documentation (logo, promotional website pretty well-done, even the cool company behind it…).
The aesthetic and educational parts I have always a significant influence and are parts of my selection criteria. But to be truly fair and somehow objective, I had to benchmark some other free tools available to achieve the same objectives. For this purpose, I have selected 2 of the famous other builders:
- Laravel Admin Panel from http://laraadmin.com
- Laravel Generator from http://labs.infyom.com/laravelgenerator/
For those, who be already tired to read this article as I am tired to writing it 🙂 Better reveal the conclusion right away, after this is not the Oscars so the winner is… Navigator. Why? Why such an injustice? Because, just have a look to the numerous screen captures not of the tool itself but the previous steps I have made to make it work. For a non-developer like me, it is far too complicated, even thought I have succeeded to install both of the builders. Harshly, I consider as a waste of time what is not dedicated only to the pure work on the dashboard screens but these tools are not for me even so they are excellent for real developer I suppose.
LARAADMIN
The first package is quite easy to install, at least here is the following commands to install it in a brand new project. Mine is called test_laraadmin_1
and the main directory where I am making the experiments on these builders is called _laravel_admin_crud_builder
Source: http://laraadmin.com/docs/1.0/installation
1. Install Laravel and create a project
Go to the main directory
cd [path-to-laravel-install]/_laravel_admin_crud_builder/ |
Create the directory for your Laravel project
composer create-project laravel/laravel=5.2.31 test_laraadmin_1 |
Get into the directory test_laraadmin_1
cd test_laraadmin_1 |
Enable the rights on the some internal directories of the project and testing the laravel install, check http://localhost:8000/
chmod -R 777 storage/ bootstrap/ database/migrations/ php artisan serve |
2. Install LaraAdmin Package
Install the laraadmin pakage in your laravel project
composer require "dwij/laraadmin:1.0.40" |
Add LaraAdmin Service providerDwij\Laraadmin\LAProvider::class in config/app.php
'providers' => [ /* The rest of the the stuff is here */ /* * Add LaraAdmin Service provider */ Dwij\Laraadmin\LAProvider::class, ], |
Run installer command
php artisan la:install |
Do not forget to change the database connection. My db is named laravel_laraadmin_demo_1
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_laraadmin_demo_1 DB_USERNAME=root DB_PASSWORD=root |
Register with username and password
name : my_super_user
email: mysuperpwd1@gmail.com
pwd: mysuperpwd1 |
Launch the migrations
php artisan migrate |
In the MYSQL Sequel Pro for the database laravel_laraadmin_demo_1
Get into the laraadmin
If you need to rollback with the migrations
php artisan migrate:rollback |
INFYOM ADMINLTE GENERATOR
I have mostly applied what was given in this video named Laravel CRUD Generator. Except that I have changed the database and so the 3 tables in the database. It has to reflect my data model. I have made also 2 relationship between the tables : TABLE Articles and TABLE Journalists, TABLE Tags and TABLE Articles within the help of unique id.
https://www.youtube.com/watch?v=K3obgSc0bdo
This video has a real charm : first it is instructive. It is in the Spanish from Peru and you get all the salt from street sound and “men at work” around the 6:30. Sure that is a good practise both for attention and coding.
Go to the correct directory
cd [path-to-laravel-install]/_laravel_admin_crud_builder/ |
Make a clone of the repository and create your project at the same time test_InfyOm_adminlte_3
git clone https://github.com/InfyOmLabs/adminlte-generator.git test_InfyOm_adminlte_3 |
Inside the directory launch a composer install
composer install |
Create the “2ème” db laravel_infyom_adminlte_demo_3
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_infyom_adminlte_demo_3 DB_USERNAME=root DB_PASSWORD=root |
Generate the key
php artisan key:generate |
Test the laravel install with infyom adminlte. Check http://localhost:8000/login
cd test_InfyOm_adminlte_3
php artisan serve |
Generate the documentation in swagger in config > infyom > laravel_generator.php
/* |-------------------------------------------------------------------------- | Add-Ons |-------------------------------------------------------------------------- | */ 'add_on' => [ 'swagger' => true, |
Here is a model of command php artisan infyom:api_scaffold $MODEL_NAME
from https://medium.com/huia/testing-1b3aaf8b3dd5
The command for the first table: Journalists. MySQL already exist so I had to figure out what was the equivalent for infyom to my regular SQL fields. You can find some information at http://labs.infyom.com/laravelgenerator/docs/5.3/getting-started
php artisan infyom:api_scaffold Journalists |
For name — varchar(191)
name string text |
For displayName — varchar(180)
displayName string text |
For addressCity — longblob
addressCity text textarea |
The command for the second table: Articles
php artisan infyom:api_scaffold Articles |
For author_id — integer (create a relationship between 2 tables)
author_id integer:unsigned:foreign,journalists,id select |
For title — varchar(191)
title string text |
For excerpt — text 65535
excerpt text textarea |
For body — text 65535
body text textarea |
For image — varchar(191)
image string text |
The command for the third table: Tags
php artisan infyom:api_scaffold Tags |
For article_id — integer (create a relationship between 2 tables)
article_id integer:unsigned:foreign,articles,id select |
For name varchar(200)
name string text |
For slug varchar(200)
slug string text |
Change to make in fields.blade.php for resources > views > articles
{!! Form::select('author_id', ], null, ['class' => 'form-control']) !!} /* change */ {!! Form::select('author_id', $journalists, null, ['class' => 'form-control']) !!} |
{!! Form::select('article_id', ], null, ['class' => 'form-control']) !!} /* change */ {!! Form::select('article_id', $articles, null, ['class' => 'form-control']) !!} |
Change_to_make in ArticlesController.php or TagsController.php
and add the models to the controller
/* change */ use App\Models\journalists; |
Add the value $journalists to the controller in ArticlesController.php
/* change */ $journalists = journalists::pluck('name','id'); return view('articles.create', compact('journalists')); |
Add the models to the controller in TagsController.php
/* change */ use App\Models\articles; |
Add the value $articles to the controller in TagsController.php
/* change */ $articles = articles::pluck('title','id'); return view('tags.create', compact('articles')); |
Change in table.blade.php in in order to call an object
<!-- <td>{!! $articles->author_id !!}</td> --> <td>{!! $articles->journalists->name !!}</td> |
if you need to TRUNCATE TABLE table_name;
--- connect to mysql server mysql -u root -p; --- show and use the db SHOW DATABASES; USE laravel_infyom_adminlte_demo_3; SHOW TABLES; --- force the truncate action SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE articles; TRUNCATE TABLE tags; SET FOREIGN_KEY_CHECKS = 1; |
If you need to debug in Laravel
dd($value); |
Read more
- Laravel Admin Panel
http://laraadmin.com/ - Installation of Laraadmin
http://laraadmin.com/docs/1.0/installation - Como generar CRUD en Laravel 5 con Laravel API Generator (spanish)
https://styde.net/como-generar-crud-con-laravel-5-api-generator/ - Using InfyOm’s Laravel Generator to efficiently scaffold an Events System – Part 1 CRUD
https://www.develodesign.co.uk/news/laravel/infyom-scaffold-generator/ - The github account of InfyOm Labs
https://github.com/InfyOmLabs/ - A serie of videos on InfyOm
https://www.youtube.com/results?search_query=InfyOm+Labs - A good video in Spanish about InfyOm named Laravel CRUD Generator
https://www.youtube.com/watch?v=K3obgSc0bdo - Voyager, The Missing Laravel Admin
https://laravelvoyager.com/ - Josh – Laravel Admin Template + Front End + CRUD ($28)
https://codecanyon.net/item/josh-laravel-admin-template-front-end-crud/8754542 - JOSH Laravel Admin + CRUD Builder
https://joshadmin.com/ - 13 Laravel Admin Panel Generators of PovilasKorop
https://laravel-news.com/13-laravel-admin-panel-generators - My previous article about Voyager: Laravel, Navigator – Discovering Navigator an admin panel generator for Laravel
https://flaven.fr/2017/11/laravel-navigator-discovering-navigator-an-admin-panel-generator-for-laravel/