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:

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

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

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

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

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,
 
    ],

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Run installer command

php artisan la:install

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

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

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Register with username and password

name : my_super_user
email: mysuperpwd1@gmail.com
pwd: mysuperpwd1

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Launch the migrations

php artisan migrate

In the MYSQL Sequel Pro for the database laravel_laraadmin_demo_1
Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Get into the laraadmin
Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard wit;h builder like laraadmin or Infyom

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

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

Laravel, CRUD - Generate a Laravel Admin CRUD dashboard with builder like laraadmin or Infyom

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