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

Jetstream Crud Laravel Package

goodyweb/jetstream-crud

Generate Jetstream-ready CRUD modules (Create, Read, Update, Delete) for any table with one Artisan command. Scaffolds bare Livewire components and Blade views with search and pagination, so you can manage records quickly in Laravel apps.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Install the Package

    composer require goodyweb/jetstream-crud dev-master
    

    Ensure legacy_model_binding is enabled in config/livewire.php:

    'legacy_model_binding' => true,
    
  2. Generate a CRUD Module Run the Artisan command with your model and Livewire component names:

    php artisan generate:crud --model=Person --livewire=Persons
    

    This creates:

    • A Livewire component (app/Http/Livewire/Persons.php)
    • Blade templates (resources/views/livewire/persons/...)
    • A migration (if not already created)
  3. First Use Case

    • Include the Livewire component in a Blade view:
      @livewire('persons.index')
      
    • Navigate to the route (e.g., web.php):
      Route::get('/persons', [PersonsController::class, 'index'])->name('persons.index');
      

Implementation Patterns

Usage Patterns

  1. Model Binding The package uses Livewire’s legacy model binding to auto-load models in the component. Example:

    public $person; // Auto-bound to the model ID in the URL (e.g., `/persons/1/edit`)
    
  2. Form Handling

    • Create/Update: Use create() and update() methods in the Livewire component:
      public function create()
      {
          $this->validate([
              'name' => 'required',
              'email' => 'required|email',
          ]);
          Person::create($this->input());
          session()->flash('message', 'Record created!');
      }
      
    • Validation: Leverage Livewire’s built-in validation rules.
  3. Search and Pagination

    • Search is implemented via a search input field in the index view.
    • Pagination uses Laravel’s paginate():
      public function getPersonsProperty()
      {
          return Person::query()
              ->when($this->search, fn($q) => $q->where('name', 'like', "%{$this->search}%"))
              ->paginate(10);
      }
      
  4. Route Integration Define routes in web.php for index, create, edit, and delete actions:

    Route::get('/persons', [PersonsController::class, 'index'])->name('persons.index');
    Route::get('/persons/create', [PersonsController::class, 'create'])->name('persons.create');
    Route::post('/persons', [PersonsController::class, 'store'])->name('persons.store');
    
  5. Customization

    • Override generated Blade templates in resources/views/livewire/persons/ to modify UI.
    • Extend the Livewire component logic (e.g., add custom queries or business logic).

Gotchas and Tips

Pitfalls

  1. Legacy Model Binding Requirement

    • Forgetting to set 'legacy_model_binding' => true in config/livewire.php will break model binding in routes like /persons/{id}/edit.
  2. Migration Conflicts

    • If the table already exists, the generator may fail or overwrite existing migrations. Manually create the migration first if needed.
  3. Livewire Component Naming

    • The --livewire flag must match the component class name (e.g., Personsapp/Http/Livewire/Persons.php). Mismatches cause "Component not found" errors.
  4. CSRF Token Issues

    • Ensure Blade forms include @csrf or @method('PUT') for update/delete actions to avoid CSRF errors.

Debugging

  • Component Not Loading? Check:

    • The Livewire component class exists in app/Http/Livewire/.
    • The Blade template paths are correct (e.g., resources/views/livewire/persons/index.blade.php).
    • No typos in the @livewire directive.
  • Validation Errors Use dd($this->validate()) in the Livewire component to inspect validation rules and input data.

Config Quirks

  • Livewire Configuration If using Livewire 3.x, ensure compatibility by checking the package’s composer.json for Laravel/Livewire version constraints.

Extension Points

  1. Add Custom Fields Extend the model and update the Livewire component’s rules() and input() methods:

    protected $rules = [
        'name' => 'required',
        'email' => 'required|email',
        'custom_field' => 'nullable', // Add new fields
    ];
    
  2. Modify Queries Override the getPersonsProperty() method to add scopes or relationships:

    public function getPersonsProperty()
    {
        return Person::with('relationship')->paginate(10);
    }
    
  3. Add Actions Include custom buttons (e.g., "Export") in the Blade template and handle them in the Livewire component:

    <button wire:click="export">Export</button>
    
    public function export()
    {
        // Logic to export data
    }
    
  4. Authorization Use Laravel’s gates/policies or Livewire’s authorize() method:

    public function delete($id)
    {
        $this->authorize('delete', Person::find($id));
        Person::find($id)->delete();
    }
    
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.
sayedenam/sayed-dashboard
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