Generate the livewire class and view for a model using the fillable attributes or the database columns, by running one command and providing the table name as argument this package generate the files (class/view) with all CRUD functions
- Use the model instance as public variable
- Use Jetstream components
- Create , Update and Delete using modals
- Manage inputs and types directly from the livewire class
- Paginations
- Laravel 8+
- Jetstream with livewire stack
You can install the package via Composer
composer require medrachy/crud-livewire
After installation, run this command
php artisan crud:build {tableName} //example : users
This command will perfom below actions :
- generate the proper (className, modelName and viewName) from the tableName
- create livewire directory if it doesn't exist "/app/Http/Livewire"
- generate the livewire class "/app/Http/Livewire/{className}.php"
- create livewire directory if it doesn't exist "/resources/views/livewire"
- generate the livewire view "/resources/views/livewire/{viewName}.blade.php"
Next open the livewire class generated "/app/Http/Livewire/{className}.php" and add the proper properties for $rules and $inputTypes
// Add the input type for each attribute
public array $inputTypes = [
// 'attribute' => 'inputType',
// example :
'name' => 'text',
'email' => 'email',
];
// Add rules
protected $rules = [
// 'modalName.attribute' => 'required',
// example :
'user.name' => 'required',
'user.email' => 'required|email',
];
And thats it, now you can render you livewire component like so :
<div>@livewire('{viewName}') // example @livewire('user-crud)</div>
This package use Jetstream modal component, if you dont use Jetstream in your application you need to edit the view generated by this package.
The MIT License (MIT). Please see License File for more information