Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Tall Crud Generator Laravel Package

ascsoftw/tall-crud-generator

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. 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
    
  2. Install the Package:

    composer require ascsoftw/tall-crud-generator
    
  3. Publish Views (Optional): If you plan to customize the UI, publish the default views:

    php artisan vendor:publish --provider="Ascsoftw\TallCrudGenerator\TallCrudGeneratorServiceProvider" --tag=views
    
  4. First Use Case:

    • Include the generator component in a Blade view (e.g., resources/views/admin/dashboard.blade.php):
      @livewire('tall-crud-generator')
      
    • Navigate to the page in your browser to access the CRUD generator UI.

Where to Look First

  • Generator UI: The @livewire('tall-crud-generator') component renders a form where you can configure CRUD operations (e.g., model, fields, relationships).
  • Documentation: Focus on the README for field/relationship syntax and examples.
  • Published Views: If customized, check resources/views/vendor/tall-crud-generator for Blade templates.

Implementation Patterns

Workflows

  1. Model-Based Generation:

    • Select a model (e.g., User) from a dropdown in the generator UI.
    • Define fields (e.g., name, email) and their types (e.g., text, email).
    • Configure relationships (e.g., belongsTo, hasMany) via syntax like:
      posts:hasMany:Post
      
    • Click "Generate" to create:
      • Livewire component (e.g., UserCrud).
      • Blade view (e.g., user-crud.blade.php).
      • Validation rules (e.g., UserCrudRequest).
  2. Reusable Components:

    • Generated CRUD components follow a consistent naming convention ({Model}Crud) and can be reused across the app.
    • Example: Reuse UserCrud in multiple views or embed it in layouts.
  3. Customization:

    • Views: Override published Blade templates (e.g., create.blade.php, edit.blade.php) in resources/views/vendor/tall-crud-generator.
    • Logic: Extend generated Livewire classes by creating a custom component (e.g., app/Http/Livewire/CustomUserCrud.php) and overriding methods like rules() or mount().
  4. Integration with Existing Code:

    • Validation: Extend generated *CrudRequest classes to add custom rules:
      public function rules()
      {
          return array_merge(parent::rules(), [
              'custom_field' => 'required|unique:table',
          ]);
      }
      
    • Events: Listen to generated CRUD events (e.g., saved, deleted) in EventServiceProvider:
      protected $listen = [
          \Ascsoftw\TallCrudGenerator\Events\CrudSaved::class => [
              \App\Listeners\LogCrudAction::class,
          ],
      ];
      
  5. Batch Operations:

    • Use the generator to create multiple CRUDs in one session (e.g., for User, Post, Comment models) and organize them in a dedicated admin panel.

Tips for Daily Use

  • Field Types: Refer to the README for supported field types (e.g., text, select, checkbox, rich_text).
  • Relationships: Use shorthand syntax for relationships (e.g., author:belongsTo:User).
  • Tailwind Styling: Customize the UI by modifying the published Blade templates with Tailwind classes.
  • Livewire Hooks: Override Livewire lifecycle methods (e.g., updated(), deleting()) in custom components for side effects.

Gotchas and Tips

Pitfalls

  1. Dependency Conflicts:

    • Ensure Livewire, Tailwind, and AlpineJS versions are compatible with the package (last updated in 2022). Test with:
      livewire/livewire: ^3.0
      tailwindcss: ^3.0
      alpinejs: ^3.0
      
    • If issues arise, check the GitHub Issues for workarounds.
  2. Model Namespace:

    • The generator assumes models are in the default 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.
  3. Field Validation:

    • Generated validation rules may not cover all edge cases. Always extend *CrudRequest classes for custom logic:
      public function rules()
      {
          return array_merge(parent::rules(), [
              'email' => 'required|email|unique:users,email,'.$this->id,
          ]);
      }
      
  4. Relationship Loading:

    • Eager loading relationships is not automatic. Use with() in the generated component’s mount() method:
      public function mount()
      {
          $this->model = User::with('posts')->find($this->id);
      }
      
  5. Tailwind Conflicts:

    • If Tailwind classes clash with the package’s defaults, override the published views and remove/replace conflicting classes (e.g., bg-gray-100).

Debugging

  1. Generated Files:

    • Check the app/Http/Livewire directory for generated CRUD components and app/Http/Requests for validation rules.
    • Look for errors in storage/logs/laravel.log if the generator fails silently.
  2. Livewire Errors:

    • Use php artisan livewire:discover to refresh Livewire components after manual changes.
    • Clear Livewire cache if components don’t update:
      php artisan livewire:cache
      
  3. Generator UI Issues:

    • If the @livewire('tall-crud-generator') component doesn’t render, verify:
      • The Livewire component is registered in app/Providers/AppServiceProvider.php:
        public function boot()
        {
            $this->loadViewsFrom(__DIR__.'/../../resources/views/vendor/tall-crud-generator', 'tall-crud-generator');
        }
        
      • No JavaScript errors (check browser console).

Extension Points

  1. Custom Field Types:

    • Extend the package by creating custom field types. Override the 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);
      }
      
  2. Event Listeners:

    • Listen to CRUD events (e.g., 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]);
      }
      
  3. API Endpoints:

    • Generate API resources by extending the Livewire component to return JSON responses:
      public function render()
      {
          return response()->json($this->model);
      }
      
    • Use Laravel’s API resources for structured responses.
  4. Multi-Tenant Support:

    • Override the getModel() method to scope queries by tenant:
      protected function getModel()
      {
          return Tenant::current()->models()->findOrFail($this->id);
      }
      

Configuration Quirks

  1. Default Values:

    • The generator uses default values for fields (e.g., text for strings). Override these in the UI or via custom components.
  2. View Publishing:

    • After publishing views, clear the view cache:
      php artisan view:clear
      
  3. Livewire Assets:

    • Ensure Livewire assets are compiled:
      npm run dev
      php artisan livewire:publish
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours