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

Foocrud Laravel Package

footility/foocrud

footility/foocrud is a Laravel/PHP package for building CRUD features quickly. Provides scaffolding and helpers to create, read, update, and delete resources with less boilerplate, aimed at speeding up admin panels and basic data management.

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation

    composer require footility/foocrud
    

    Publish the config (if available) and run migrations:

    php artisan vendor:publish --provider="Footility\Foocrud\FoocrudServiceProvider"
    php artisan migrate
    
  2. Basic Setup Register the package in config/app.php under providers:

    Footility\Foocrud\FoocrudServiceProvider::class,
    
  3. First Use Case: Quick CRUD for a Model Assume you have a Post model. Create a controller to leverage foocrud:

    use Footility\Foocrud\CrudController;
    
    class PostCrudController extends CrudController
    {
        public function model()
        {
            return \App\Models\Post::class;
        }
    }
    

    Define a route in routes/web.php:

    Route::resource('posts', \App\Http\Controllers\PostCrudController::class);
    
  4. Explore the README Check the GitHub README for model binding, field customization, and view overrides.


Implementation Patterns

Core Workflows

  1. Model Binding Extend CrudController and override model() to bind to any Eloquent model:

    public function model()
    {
        return \App\Models\User::class;
    }
    
  2. Field Customization Use crudFields() to define which fields appear in forms/views:

    protected function crudFields()
    {
        return [
            'name', 'email', 'is_active'
        ];
    }
    
  3. View Overrides Override default views by publishing assets:

    php artisan vendor:publish --tag=foocrud-views
    

    Then customize resources/views/vendor/foocrud/.

  4. Authorization Integrate with Laravel’s gates/policies:

    public function authorizeCreate()
    {
        return auth()->user()->can('create', $this->model());
    }
    
  5. API Support Extend CrudController for API responses:

    public function store(Request $request)
    {
        $data = $this->create($request);
        return response()->json($data, 201);
    }
    

Integration Tips

  • Laravel Mix/Vite: Use foocrud’s JS assets for dynamic forms (if provided).
  • Validation: Extend validateCreate()/validateUpdate() for custom rules.
  • Relationships: Handle belongsTo/manyToMany via with() in model() or nested forms.

Gotchas and Tips

Common Pitfalls

  1. Missing Config If views/routes fail, ensure foocrud is registered in config/app.php and config published.

  2. Model Not Found Verify the model() method returns a fully qualified class name (e.g., \App\Models\Post).

  3. Field Mismatches If fields don’t render, check:

    • The model’s $fillable array.
    • Typos in crudFields().
    • Database column names (case-sensitive in some DBs).
  4. Route Conflicts Avoid naming conflicts with existing Route::resource calls. Use unique prefixes:

    Route::prefix('admin')->resource('posts', PostCrudController::class);
    

Debugging Tips

  • Log Model Binding:
    dd($this->model()); // Verify class name in controller.
    
  • Check Published Views:
    php artisan vendor:publish --tag=foocrud-views --force
    
  • Enable Debug Mode: Set APP_DEBUG=true in .env to surface template errors.

Extension Points

  1. Custom Actions Add methods like actionDelete() to extend functionality:

    public function actionDelete($id)
    {
        $model = $this->model::findOrFail($id);
        $model->delete();
        return redirect()->route('posts.index')->with('success', 'Deleted!');
    }
    
  2. Hooks Override lifecycle methods (e.g., beforeCreate(), afterUpdate()).

  3. Blade Directives If the package uses directives (e.g., @crudForm), check app/Providers/AppServiceProvider for registration.

  4. Testing Mock the controller in PHPUnit:

    $controller = new PostCrudController();
    $controller->model = Mockery::mock(\App\Models\Post::class);
    
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor