Download the PHP package radfic/gastropod without Composer
On this page you can find all versions of the php package radfic/gastropod. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package gastropod
PLEASE NOTE THAT GASTROPOD IS STILL IN PRE-ALPHA STAGE, USE IT FOR EXPERIMENT OR IF YOU WANT TO CONTRIBUTE BUT DON'T USE IT IN A PRODUCTION ENVIRONMENT.
Gastropod a simple Laravel package, loosely inspired by Grocery Crud package for Code Igniter, and intended to speed up and ease the creation of crud based admin pages for small websites. It assumes you already have a users table and a User Eloquent model to automatically create a simple Users and Admin crud. You can then further expand it to have it manage all of your tables, and you can setup a basic, yet expandable, crud system with very few lines of code. Gastropod views are created with Bootstrap and jQuery, and it pulls it's needed scripts and css from cdns without having you to do anything. Its Auth is based on existing Laravel Auth system, only adding a table to reference which users will be admitted to the crud. But users will still login against your own users table without having to modify it.
1)Install from composer
You can install the package using composer:
2)Run the artisan install script
After that you will have to run the gastropod:install
artisan command:
It will publish a number of files in your app's directory structure:
3)Run Migrations
After publishng your assets, a new migration will be present in your app's migrations folder: 2022_02_13_172741_create_gastropod_admins_table.php
.
It defines a new table in your database to hold reference to users allowed to access gastropod.
3)Now you should run your migrations to let artisan create the table for you, by running the artisan migrate command:
After running your migrations you should have a new table in your db: 'gastropod_admins'.
Gastropod is assuming you have a users table and a User model in your app already. To let users use Gastropod you will have to add a record in this table per user, referencing the id of the user. The first Gastropod Admin has to be set with your own means (for example with PhpMyAdmin). Once Gastropo is installed you will add more admins using it's interface.
3.1)Create First Admin
Manually add a first admin inserting a new record in gastropod_admins
, referencing a users table row:
This user will now be allowed to login into gastropod. Every further user you would like to give access to Gastropod should have a related record in this table.
4)Register Gastropod Routes in RouteServiceProvider
Last step is registering gastropod routes into your app's RouteServiceProvider. To do this open the file app\Providers\RouteServiceProvider.php
and add the gastropod bit after all other entries in the boot function:
Finished: check your installation!
Go to the /gastropod
route to see if the login page is showing up. If it does you should login with the user related to the record you inserted before in the gastropod_admins
table. If everything went fine you should see your users table now. And also a gastropod_admins table should be set up and accessible via the menu.
Create your first gastropod crud
If your Gastropod is up and running next thing you want to know is how to add models to the crud.
So lets begin with an example created from a real life scenario: you want to add a users
table. Gastropod is always assuming that you already have your tables set up and your models, with all relevant relations defined, in place before you try to create a new crud, so lets assume we have already our tables and models: a users
table and a User
model.
Lets start by using the custom artisan make:gastropodController
command. It will need two parameters:
- The name of the Controller you will create, for users controller i would suggest something like:
Gastropod\GastropodUserController
. Please note that this way the controller class file will be created in the Gastropod Folder under yourapp/Http/Controllers
folder. - The name of the model you want to crud. In this example we want to crud the User model.
After that you will have a brand new Gastropod controller in your App. Check it out since you may want to modify it:
Since our User model doesen't have relations to be considered our controller is ready as is. Now we just need to add the resource in our routes/gastropod.php
file:
There we will add a user
entry after the default gastropod_admins
entry. This will register all the relevant resource routes for our crud. Now we just have to test it out.
Point your browser to the route gastropod/users
and you should be presented with the right crud.
Last thing you may want to do is update the Gastropod template view to add the user link to the navigation menu. So open the file resources\views\gastropod\template.blade.php
and modify its nav bar as follows:
That's it. Happy Gastropoding!