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

Crudit Laravel Package

ekolustudio/crudit

Laravel package for rapid CRUD scaffolding and admin-style interfaces. Generate controllers, models, views and routes to speed up building create/read/update/delete features with less boilerplate and a consistent structure.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require ekolustudio/crudit
    

    Publish the package config (if needed):

    php artisan vendor:publish --provider="Ekolustudio\Crudit\CruditServiceProvider"
    
  2. Basic Usage Register the CRUD routes in routes/web.php:

    use Ekolustudio\Crudit\Facades\Crudit;
    
    Crudit::routes('App\Models\User'); // Auto-generates CRUD routes for User model
    
  3. First Use Case

    • Access the generated routes (e.g., /crudit/users for listing, /crudit/users/create for creation).
    • Customize the default behavior via config (config/crudit.php) or service provider overrides.

Implementation Patterns

Core Workflows

  1. Model-Based CRUD

    • Auto-Generated Controllers: The package dynamically creates CRUD controllers for any Eloquent model.
    • Example:
      Crudit::routes('App\Models\Post', [
          'except' => ['destroy'], // Exclude soft-delete route
          'only'  => ['index', 'store'], // Include only specific actions
      ]);
      
  2. Customization via Config

    • Override default views, middleware, or route names:
      'views' => [
          'prefix' => 'crudit::custom.',
      ],
      'middleware' => ['auth', 'verified'],
      
  3. Integration with Existing Apps

    • Blade Views: Extend or replace default views (e.g., resources/views/crudit/custom/index.blade.php).
    • APIs: Use the underlying logic via Crudit::controller() to build custom APIs:
      $controller = Crudit::controller('App\Models\Product');
      $controller->index(request());
      
  4. Form Customization

    • Use crudit_form directive in Blade:
      {!! crudit_form('App\Models\Order', 'update') !!}
      

Advanced Patterns

  • Dynamic Model Binding:
    Crudit::routes('App\Models\Project', [
        'bindings' => ['project' => 'slug'], // Bind by slug instead of ID
    ]);
    
  • Policy Integration:
    Crudit::policy('App\Models\Post', \App\Policies\PostPolicy::class);
    

Gotchas and Tips

Common Pitfalls

  1. Route Conflicts

    • Ensure generated routes (e.g., /crudit/{model}) don’t clash with existing routes. Use namespace in config:
      'routes' => [
          'namespace' => 'Crudit\Controllers',
      ],
      
  2. Model Requirements

    • The package assumes standard Eloquent models. Custom accessors/mutators may break form rendering.
    • Fix: Override the form view or use crudit_form with custom fields:
      {!! crudit_form('App\Models\Post', 'create', [
          'fields' => ['title', 'custom_field'],
      ]) !!}
      
  3. Caching Issues

    • Routes/views are auto-generated. Clear config cache after updates:
      php artisan config:clear
      
  4. Middleware Gaps

    • Default middleware may not cover all cases (e.g., API tokens). Extend via config:
      'middleware' => ['auth:sanctum', 'throttle:60'],
      

Debugging Tips

  • Log Routes:
    dd(Route::getRoutes()->getByName('crudit.*'));
    
  • Inspect Controllers: The package generates controllers in app/Crudit/Controllers (if not cached). Override them for full control.

Extension Points

  1. Custom Actions
    • Add methods to the auto-generated controller:
      Crudit::extend('App\Models\Post', function ($controller) {
          $controller->addAction('publish', 'App\Http\Controllers\PublishPost');
      });
      
  2. View Overrides
    • Copy vendor/ekolustudio/crudit/resources/views to resources/views/crudit and modify.
  3. Validation Rules
    • Extend via crudit_form or override the rules method in the generated controller.
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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle