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

Scaffold Interface Laravel Package

maxolex/scaffold-interface

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation:

    composer require maxolex/scaffold-interface laravel/ui "^3.0" spatie/laravel-permission amranidev/ajaxis
    npm install && npm run dev
    

    Add providers to config/app.php:

    Maxolex\ScaffoldInterface\ScaffoldInterfaceServiceProvider::class,
    Amranidev\Ajaxis\AjaxisServiceProvider::class,
    Spatie\Permission\PermissionServiceProvider::class,
    
  2. Publish Assets:

    php artisan vendor:publish --provider="Maxolex\ScaffoldInterface\ScaffoldInterfaceServiceProvider" --force
    
  3. Run Migrations:

    php artisan migrate
    
  4. Access the Interface: Navigate to /scaffold in your browser. Authenticate using the default admin credentials (password: admin).


First Use Case: Generate a Basic CRUD

  1. Design the Table:

    • Click "Nouveau" (New) to create a scaffold.
    • Define fields (e.g., name, email) with types (e.g., string, email).
    • Configure primary key, timestamps, and soft deletes if needed.
  2. Generate:

    • Click "Générer" (Generate). The package creates:
      • Model (app/Models/YourModel.php),
      • Migration (database/migrations/..._create_your_models_table.php),
      • Controller (app/Http/Controllers/YourModelController.php),
      • Views (resources/views/your_model/...),
      • Routes (routes/web.php),
      • AdminLTE dashboard integration.
  3. Test:

    • Visit /your-model to see the generated CRUD interface.

Implementation Patterns

Workflow: Iterative Scaffolding

  1. Design-First Approach:

    • Use the interface to sketch tables before writing code. Visualize relationships (e.g., OneToMany, ManyToMany) via the graph tool.
    • Example: Define a Post model with a ManyToMany relationship to Tag. The package auto-generates:
      • Pivot table migration,
      • Relationship methods in the model,
      • Intermediate CRUD views for managing tags.
  2. Reusable Templates:

    • Leverage Bootstrap/Materialize views by selecting themes in the interface.
    • Customize templates by overriding default views in resources/views/vendor/scaffold-interface/.
  3. Package Integration:

    • Generate CRUD for Laravel packages (e.g., lpackager) by pointing the scaffold to the package’s config path:
      // In the interface, specify:
      'package_path' => base_path('vendor/your-package'),
      
  4. AdminLTE Dashboard:

    • Auto-integrate generated CRUDs into AdminLTE menus. Edit resources/views/layouts/admin.blade.php to customize the sidebar.
  5. WebSocket Notifications:

    • Enable Pusher for real-time updates (e.g., live CRUD changes). Configure .env:
      BROADCAST_DRIVER=pusher
      PUSHER_APP_ID=your_app_id
      PUSHER_APP_KEY=your_key
      PUSHER_APP_SECRET=your_secret
      

Integration Tips

  • Seeding Data: Use the interface to generate a seeder alongside the model. Example:

    // Auto-generated in database/seeds/YourModelTableSeeder.php
    public function run()
    {
        YourModel::create(['name' => 'Test', 'email' => '[email protected]']);
    }
    

    Run with:

    php artisan db:seed --class=YourModelTableSeeder
    
  • Rollback: Use the interface’s "Annuler" (Rollback) button to revert migrations/views. Alternatively, manually:

    php artisan migrate:rollback
    
  • Soft Deletes: Enable in the interface for models. The package adds:

    use Illuminate\Database\Eloquent\SoftDeletes;
    protected $dates = ['deleted_at'];
    

    And configures the controller to handle soft deletes.

  • Permissions: Integrate with spatie/laravel-permission via the interface. Assign roles to generated CRUDs in the AdminLTE users management panel.


Gotchas and Tips

Pitfalls

  1. French Documentation:

    • The interface and error messages are in French. Key terms:
      • "Générer" = Generate,
      • "Annuler" = Rollback,
      • "Modèle" = Model,
      • "Relation" = Relationship.
  2. Namespace Conflicts:

    • If your app uses custom namespaces (e.g., App\Models\), ensure the scaffold respects them. Override the default namespace in the interface’s advanced settings.
  3. AdminLTE Overrides:

    • Customizing AdminLTE (e.g., resources/views/layouts/admin.blade.php) may break auto-generated menus. Use:
      @include('scaffold-interface::partials.admin-menu')
      
      To re-integrate scaffolded items.
  4. WebSocket Dependencies:

    • Pusher notifications require a Pusher account and proper .env configuration. Without it, WebSocket features (e.g., live updates) will fail silently.
  5. Migration Rollback Issues:

    • Rolling back migrations via the interface may leave orphaned views/controllers. Manually delete unused files in:
      app/Http/Controllers/
      resources/views/
      routes/web.php
      

Debugging

  1. Logs:

    • Check storage/logs/laravel.log for scaffold-related errors (e.g., permission issues, missing dependencies).
  2. Artisan Commands:

    • Use php artisan scaffold:list to see all generated scaffolds.
    • Use php artisan scaffold:rollback [name] to revert a specific scaffold.
  3. View Overrides:

    • If generated views conflict with your templates, override them in:
      resources/views/vendor/scaffold-interface/
      
    • Example: Copy resources/views/vendor/scaffold-interface/partials/form.blade.php to your project and modify.

Extension Points

  1. Custom Field Types:

    • Extend the scaffold’s field types by publishing and modifying the config:
      php artisan vendor:publish --tag=scaffold-config
      
    • Edit config/scaffold-interface.php to add custom field options (e.g., enum, json).
  2. Hooks:

    • Add logic before/after generation by binding events in AppServiceProvider:
      use Maxolex\ScaffoldInterface\Events\ScaffoldGenerated;
      
      public function boot()
      {
          event(ScaffoldGenerated::class, function ($event) {
              // Post-generation logic (e.g., seed data, send notifications)
          });
      }
      
  3. Relationship Macros:

    • Extend relationship handling by adding macros to the scaffold’s relationship manager:
      use Maxolex\ScaffoldInterface\Managers\RelationshipManager;
      
      RelationshipManager::macro('customRelation', function ($model, $relation) {
          // Custom logic for unsupported relationships
      });
      
  4. Testing:

    • Test generated CRUDs with Laravel’s HTTP tests. Example:
      public function test_crud_operations()
      {
          $response = $this->get('/your-model/create');
          $response->assertStatus(200);
      }
      
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle