Install Dependencies: Ensure your Laravel project has Livewire, TailwindCSS, and AlpineJS installed and configured.
composer require livewire/livewire
npm install -D tailwindcss alpinejs
npm run dev
Install the Package:
composer require ascsoftw/tall-crud-generator
Publish Views (Optional): If you plan to customize the UI, publish the default views:
php artisan vendor:publish --provider="Ascsoftw\TallCrudGenerator\TallCrudGeneratorServiceProvider" --tag=views
First Use Case:
resources/views/admin/dashboard.blade.php):
@livewire('tall-crud-generator')
@livewire('tall-crud-generator') component renders a form where you can configure CRUD operations (e.g., model, fields, relationships).resources/views/vendor/tall-crud-generator for Blade templates.Model-Based Generation:
User) from a dropdown in the generator UI.name, email) and their types (e.g., text, email).belongsTo, hasMany) via syntax like:
posts:hasMany:Post
UserCrud).user-crud.blade.php).UserCrudRequest).Reusable Components:
{Model}Crud) and can be reused across the app.UserCrud in multiple views or embed it in layouts.Customization:
create.blade.php, edit.blade.php) in resources/views/vendor/tall-crud-generator.app/Http/Livewire/CustomUserCrud.php) and overriding methods like rules() or mount().Integration with Existing Code:
*CrudRequest classes to add custom rules:
public function rules()
{
return array_merge(parent::rules(), [
'custom_field' => 'required|unique:table',
]);
}
saved, deleted) in EventServiceProvider:
protected $listen = [
\Ascsoftw\TallCrudGenerator\Events\CrudSaved::class => [
\App\Listeners\LogCrudAction::class,
],
];
Batch Operations:
User, Post, Comment models) and organize them in a dedicated admin panel.text, select, checkbox, rich_text).author:belongsTo:User).updated(), deleting()) in custom components for side effects.Dependency Conflicts:
livewire/livewire: ^3.0
tailwindcss: ^3.0
alpinejs: ^3.0
Model Namespace:
App\Models). For custom namespaces (e.g., App\Modules\User\Models), manually specify the full path in the generator UI or override the getModel() method in a custom component.Field Validation:
*CrudRequest classes for custom logic:
public function rules()
{
return array_merge(parent::rules(), [
'email' => 'required|email|unique:users,email,'.$this->id,
]);
}
Relationship Loading:
with() in the generated component’s mount() method:
public function mount()
{
$this->model = User::with('posts')->find($this->id);
}
Tailwind Conflicts:
bg-gray-100).Generated Files:
app/Http/Livewire directory for generated CRUD components and app/Http/Requests for validation rules.storage/logs/laravel.log if the generator fails silently.Livewire Errors:
php artisan livewire:discover to refresh Livewire components after manual changes.php artisan livewire:cache
Generator UI Issues:
@livewire('tall-crud-generator') component doesn’t render, verify:
app/Providers/AppServiceProvider.php:
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../../resources/views/vendor/tall-crud-generator', 'tall-crud-generator');
}
Custom Field Types:
fields() method in a custom component and register new field classes in the service provider:
// app/Providers/AppServiceProvider.php
public function boot()
{
TallCrudGenerator::extend('custom_field', \App\Fields\CustomField::class);
}
Event Listeners:
CrudSaved, CrudDeleted) to trigger side effects like notifications or logging:
// app/Listeners/LogCrudAction.php
public function handle(CrudSaved $event)
{
Log::info('CRUD saved', ['model' => $event->model]);
}
API Endpoints:
public function render()
{
return response()->json($this->model);
}
Multi-Tenant Support:
getModel() method to scope queries by tenant:
protected function getModel()
{
return Tenant::current()->models()->findOrFail($this->id);
}
Default Values:
text for strings). Override these in the UI or via custom components.View Publishing:
php artisan view:clear
Livewire Assets:
npm run dev
php artisan livewire:publish
How can I help you explore Laravel packages today?