Download the PHP package innovmt/mt-jetstream-inertia-generator without Composer
On this page you can find all versions of the php package innovmt/mt-jetstream-inertia-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innovmt/mt-jetstream-inertia-generator
More information about innovmt/mt-jetstream-inertia-generator
Files in innovmt/mt-jetstream-inertia-generator
Package mt-jetstream-inertia-generator
Short Description Admin CRUD generator using Laravel Jetstream, Inertiajs, Vue.js, Pagetables and Tailwindcss. Project adapted from coolsam726/jetstream-inertia-generator
License MIT
Homepage https://github.com/avinashramdoyal/mt-jetstream-inertia-generator
Informations about the package mt-jetstream-inertia-generator
Jetstream Powered Admin CRUD Generator
Jetstream Inertia Generator a.k.a jig allows you to generate code for simple Admin CRUDs (Create, Read, UPdate, Delete) which are fully compatible with a Laravel Project powered by the Jetstream - Inertia - Vue.js Stack.
Scenario
You are developing a NextGen project. The data model is complex. It requires Many CRUDS managed by the admin in order to power the main end-user functionality. You don't want to spend Days or even Months writing boilerplate code for all the CRUDs. If that is you, this package comes to your rescue. Just follow these simple steps:
- Generate a Migration for your CRUD table, e.g articles, and run
php artisan migrate
(About 2 minutes) - With this package, just run
php artisan jig:generate articles
(About 3 seconds!!!) - Build your css and javascript (About 27 seconds) DONE! In about 2 and a half minutes, you get a fully working module consisting of -:
- Model
- Admin Controller - Index, Create, Show, Edit, Store, Update, Delete
- API Controller - Index, Store, Show, Update, Delete
- An Authorization Policy - viewAny, view, create, update, delete, restore, forceDelete
- Generated Permissions for spatie/laravel-permissions - articles, articles.index, articles.create, articles.show, articles.edit, articles.delete
- Frontend Menu entry
- Frontend Datatable with Actions thanks to Using Yajra Datatables and datatables.net
- Tailwindcss-powered CREATE and EDIT forms,
- Tailwindcss - powered SHOW view.
- web and API routes
- Validation and Authorization Request Classes
What more could you ask for? Cut a day's work down to less than 3 minutes.
Dependencies
If you have followed the Jetstream - Inertia - Vue.js Installation instructions, then the project will work with minimal configuration. Other Important dependencies that you MUST configure include:
- Spatie Laravel Permissions - This is used to manage roles and permissions. Its migrations will be published during asset publishing, after which you can go ahead and configure the user trait.
- Laravel Sanctum - Used to manage both API and stateful authentication. Since the whole app will be a Single Page Application, make sure you configure the middleware sanctum middleware in
app/Http/Kernel.php
as follows:
Installation
-
You can install the package via composer:
- Install the necessary
npm
dev dependencies by running the following command: If you are using npm:
Or if you are using yarn:
Feel free to configure the color palette to your own preference, but for uniformity be sure to include primary
,secondary
, success
and danger
variants since they are used in the jig template.
- Publish the Package's assets, configs, templates, components and layouts. This is necessary for you to get the admin layout and all the vue components used in the generated code:
Option 1 (Suitable for fresh installations)
Option 2 (Useful if you are upgrading the package or already have local changes you don't want to override.) NB: If you only want to update some published files, delete only the published files that you want to update, then run the appropriate command below:
- Then finish installation steps for spatie/laravel-permission by publishing its migrations.
NB: The title
field will be automatically added to the roles
and permissions
tables when the first CRUD is generated.
-
Add the
JigMiddleware
to the Global middleware and theweb
middleware group inapp/Http/Kernel.php
: -
Allow First-Party access to the Sanctum API by adding the following to the
api
middleware group inapp/Http/Kernel.php
-
Modify the .env to have the following keys:
- create the storage:link (See laravel documentation) to allow access to the public disk assets (e.g logos) via web:
Usage
The initial seeded admin user and role
When you run php artisan vendor:publish --tag=jig-migrations
, a migration is published that creates an initial default user called Administrator
and a role with the name administrator
to enable you gain access to the system with admin privileges. The credentials for the user account are:
- Email: [email protected]
- Password: password
Use these creds after migration to login and explore all parts of the application
Create the Permissions, Roles and Users Modules first, in that order:
Run the following commands to generate the User Access Control Module before proceeding to generate your admin:
You can now proceed to generate any other CRUD you want using the steps in the following section.
General Steps to generate a CRUD:
- Generate and write a migration for your table with
php artisan make:migration
command. - Run the migration to the database with
php artisan migrate
command - Generate the Whole Admin Scaffold for the module with
php artisan jig:generate
command - Modify and customize the generated code to suit your specific requirements if necessary.
__NB: If the crud already exists, and you would like to generate, you can use the
-f
or--force
option to force replacement of files.Example
Assuming you want to generate a
books
table:
-
Open your migration and modify it as necessary, adding your fields. After that, run the migration.
- The Fun Part: Scaffold a whole admin module for books with jig using the following command:
NB: To get a full list of jig
commands called under the hood and the full description of the jig:generate
command, you can run the following:
The command above will generate a number of files and add routes to both your api.php
and web.php
route files. It will also append menu entries to the published Menus.json
file.
The generated vue files are placed under the Pages/Books folder in the js folder.
- Finally, run
yarn watch, yarn dev or yarn prod
to compile the assets. There you have your CRUD.Roles, permissions and Sidebar Menu:
-
By Default, generation of a module generates the following permissions:
- index
- create
- show
- edit
- delete
- The naming convention for permissions is ${module-name}.${perm} e.g payments.index, users.create etc.
-
This package manages access control using policies. Each generated module generates a policy with the default laravel actions:
- viewAny, view, store, update, delete, restore, forceDelete The permissions generated above are checked in these policies. If you need to modify any of the access permissions, policies is where to look.
- Special permissions MUST also be generated to control access to the sidebar menus. These permissions SHOULD NOT contain two parts separated with a dot, but only one part.
- Menus are configured in a json file published at
./resources/js/Layouts/Jig/Menu.json
.- For all menu items, the json key MUST match the permision that controls that menu. A permission without any verb is generated when generating each module for this very purpose. For example, generating a
payments
module will generate apayments
permission. Then the menu for payments must havepayments
as the json key. - For parent menus and any other menus which may not match any module, you have to create a permission with the key name to control its access. For example, if you have a parent menu called
master-data
you have to generate a permission with the same name.
- For all menu items, the json key MUST match the permision that controls that menu. A permission without any verb is generated when generating each module for this very purpose. For example, generating a
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Sam Maosa
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of mt-jetstream-inertia-generator with dependencies
ext-json Version *
doctrine/dbal Version ^3.0
illuminate/support Version ^8
inertiajs/inertia-laravel Version ^0
laravel/helpers Version ^1.4
laravel/jetstream Version ^2.3
savannabits/laravel-pagetables Version ^1.0
spatie/laravel-permission Version ^4.0
yajra/laravel-datatables Version ^1.5