Download the PHP package mostafa-mohamed/laravel-crud without Composer
On this page you can find all versions of the php package mostafa-mohamed/laravel-crud. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-crud
Laravel CRUD Generator
Introduction
Please see the full documentation here.
This package adds a crud:generate command to Artisan in your Laravel project. With this command you can generate CRUD (Create, Read, Update, Delete) for your db tables instantly!
The generated CRUD includes a Controller, Model, Policy, routes, validations, and 4 view files (index, create, edit, show). It also supports relations between tables, so you can generate nested CRUDs, for example: generating CRUD for comments inside a blog post.
The output is fully customizable and supports both Bootstrap 5 and Tailwind CSS.
Demo Video
Screenshots
Index page
Laravel-crud can generate nested CRUDs. For example, you can generate CRUD for customers > tickets > replies by simply running:
Table layout
(Automatically generated index page with responsive table layout)
The generated views are fully customizable and template based. For example, you can change the look of the index page by using different templates like table, cards or chat (included in the package).
Card layout
(Card layout)
Chat layout
(Chat layout)
Create / Edit Forms
Laravel CRUD generator can automatically generate the FORM for creating and editing records. It can also generate the validation rules for the form.
(Example of generated fields)
Heads up!
The package is still in alpha
You should only use it with new projects. If you are using it in an existing project, make sure to back up (or commit) any project changes before running the command.
The aim of the CRUD generator is to save you time by generating common boilerplate CRUD code for any database table instantly.
But this code is not intended to be used as-is. You should always customize the generated code to fit your needs and manually review the generated files before deploying it to production.
Installation
Install with Composer
Via composer:
Generate files
Important!
Make sure to create the db tables and run migrations before starting the crud generator.
After installing the package you should see a
new crud:generate
command in your Artisan commands list.
To generate the Controller, Model, Policy, routes, etc use the following command:
Including the generated routes
By default, the generated routes are placed in
the ./routes/crud/
directory. To include the generated
routes just open your routes/web.php
file and add the
following line at the end of the file:
This will glob
all the generated route files and include
them in the routes/web.php
file for you.
Alternatively, you can copy-paste the generated routes from
the ./routes/crud/
directory to your routes/web.php
file. This way you make any changes to the generated route
code as per your needs.
Location of the generated files
The crud:generate
command will generate the following
files and place them in the appropriate directories:
- Resource Controller
app/Http/Controllers/[Name].php
- Model
app/Model/[Name].php
- Policy
app/Policies/[Name]Policy.php
- Routes
routes/crud/[name].php
- Views
resources/views/[name]/(index|edit|create|show).blade.php
By default, the generated code will not overwrite any
existing files. If you want to overwrite the existing files,
you can use the --force
option.
Options
CSS Framework: Bootstrap 5, and TailwindCSS.
You can choose between Bootstrap 5 and Tailwind CSS or you can use your own CSS framework. By default, Bootstrap 5 is used when nothing is specified.
Prefix
You can add a route prefix for the generated CRUD by passing
a --prefix
option.
This will change the route from /authors
to
/admin/authors
in all the generated files.
Index templates
You can choose between 3 ready-made index templates: table, cards and chat. By default, the table template is used.
Please see the index page here for screenshots.
Single create and edit form
In some cases, you may want to use a single form for both
creating and editing a resource. You can do that by passing
--merge-forms
option.
This will generate a single view
file called
create-edit.blade.php
and update the controller code
accordingly so that it can be used for both creating and
editing a resource.
Layout and section names
By default, the generated views use layouts/app.blade.php
for layout and content
for section name. You can change
these default names by passing your own layout and section
names.
Relational tables and nesting
In addition to generating simple CRUD for a single table, you can also generate CRUD for tables related to each other.
Example #1
For example, let's say we have the following tables:
- Authors
- Posts
- Comments
To generate CRUD for these tables you can use the dot
notation to specify the parent tables like this:
authors.posts.comments
.
bash
Create CRUD for authors table
$ php artisan crud:generate authors
Create CRUD for posts table
$ php artisan crud:generate authors.posts
Create CRUD for comments table
$ php artisan crud:generate authors.posts.comments bash
Create CRUD for posts table
$ php artisan crud:generate posts
Create CRUD for comments table
$ php artisan crud:generate posts.comments bash
Copy the template files into a new directory
$ php artisan crud:template newname bash
Copy the template files into a new directory
$ php artisan crud:template newname -d etc/templates bash
Generate the CRUD using the new template
$ php artisan crud:generate Post --template etc/templates/newname bash $ php artisan crud:remove customers.tickets.replies bash $ php artisan crud:remove customers.tickets.replies --backup=backup.zip
This too will remove the files from the disk but will also
create a Zip archive of all the removed files too.
# License
The software is licensed using a MIT License. It means you
can do whatever you want with it (including using it for
commercial purposes freely), as long as you include the
original copyright and license notice in any copy of the
software/source.
# Roadmap
- Add support for Livewire
- Add support for Laravel Jetstream
# About
**Found any bugs?** Report them on the [issue tracker](https://github.com/MOstafaMOhamedX/laravel-crud/issues).
**Want to contribute?** Fork the project on GitHub and send a
pull request.
**Like the project?** Star it on GitHub.