Generating BREAD from an existing Database table

Although Infyom has now been installed. It is set up to use a complicated Admin Panel approach that requires the User to be logged in. As we have not implemented User login yet we need to strip out some of the Boilerplate code used by infyom and replace it with something way simpler. Open the file \resources\views\layouts\app.blade.php - delete all the code you find in there and replace it with the first block of code you find in this post https://www.learnlaravel.net/607/view-inheritance. This will greatly simplify the overall look of the system.

Now that we have created a database, created a Larvel project and added the Infyom Admin panel generator package we are finally in a position to scaffold some Browse, Read, Edit and Delete screens for one of our database tables.

Before we can run the generate command from the command line we need to point our new Laravel project at the underlying database that we have in mind for it. To do this we need to edit the .env file in the project folder and modify the database credentials. Open the file laravel\tennisClub\.env in your preferred editor.

By default DB_DATABASE environment variable is assigned the value "Laravel". Change this to "tennisclub" as above. Now run the following command from the command line.

php artisan infyom:scaffold member --fromTable --tableName=member

The scaffolder connects to the database, pulls in the data from the member table, and uses it to generate Models Views and Controllers associated with Browse, Read, Edit and Delete functionality. Before we can view this we need to fire-up the webserver. We can use PHP's built-in webserver. At the command prompt type

php artisan serve

This will run the PHP webserver on port 8000. To see your newly scaffolded laravel application in action visit http://localhost:8000/members - you should see the following screen.

Leave a Reply