myopensoft / filament-crud-generator
to be use by ost's filament project
Requires
- php: ^8.3||^8.4
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
A Laravel package that provides a command to generate Livewire components with CRUD operations. This package simplifies the process of creating Livewire components, models, controllers, and related files for your Laravel application.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
composer require myopensoft/filament-crud-generator
You can publish the config file with:
php artisan vendor:publish --tag="filament-crud-generator-config"
This is the contents of the published config file:
return [
];
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-crud-generator-views"
Usage
After installing the package, you can use the make:filament-resource
command to generate a new set of Livewire components with CRUD operations:
php artisan make:filament-resource Post
This will create a new set of Livewire components for the Post
model with all the necessary files for CRUD operations, including a controller and Blade views.
Options
The command supports the following options:
-m, --model
: Create a model for the resource-s, --soft-deletes
: Add soft delete functionality to the model-f, --force
: Overwrite existing files-t, --table
: Specify a custom table name (default: pluralized snake_case of resource name)
Examples
Create a resource with a model:
php artisan make:filament-resource Post --model
Create a resource with a model that supports soft deletes:
php artisan make:filament-resource Post --model --soft-deletes
Force overwrite existing files:
php artisan make:filament-resource Post --force
Create a resource with a custom table name:
php artisan make:filament-resource Post --model --table=custom_posts
Configuration
You can publish the configuration file to customize the behavior of the generator:
php artisan vendor:publish --tag="filament-crud-generator-config"
This will create a filament-crud-generator.php
file in your config
directory where you can customize the namespaces, templates, and default options for the generator.
Generated Files
The command generates the following files:
- Model (optional): A basic Eloquent model with fillable attributes and table name.
- Livewire Components:
- Index component for listing records with search and pagination
- Create component for adding new records
- Edit component for updating existing records
- Blade Views: Corresponding views for each Livewire component with responsive UI.
- Controller: A controller with an index method that includes permission checking and returns a view.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- [Muhammad Syafiq Bin Zainuddin](https://github.com/Muhammad Syafiq Zainuddin)
- All Contributors
License
The MIT License (MIT). Please see License File for more information.