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

Muetze Site Laravel Package

norman-huth/muetze-site

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require norman-huth/muetze-site
    

    Publish the config file if you need to customize defaults:

    php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="config"
    
  2. First Use Case: Create a pivot table migration for a many-to-many relationship (e.g., User and Role):

    php artisan make:migration:pivot User Role
    

    This generates a migration with timestamps and foreign keys for both models.

    Create a full CRUD bundle (model + migration + policy + resource):

    php artisan make:bundle Post
    

    This leverages Laravel's built-in scaffolding but bundles it into a single command.


Implementation Patterns

Pivot Table Workflow

  • Standard Usage: Use make:migration:pivot to quickly scaffold pivot tables for polymorphic or standard many-to-many relationships. Example:

    php artisan make:migration:pivot User Role --id1=uui --id2=foo_bar
    
    • Customizes foreign key names when primary keys aren’t id.
    • Automatically names the pivot table as {Model1}{Model2} (e.g., UserRole).
  • Integration Tip: Pair with Laravel’s belongsToMany() to define relationships in models:

    public function roles()
    {
        return $this->belongsToMany(Role::class, 'user_role');
    }
    

Bundle Creation Workflow

  • Default Behavior: The make:bundle command generates:

    • Model (--m flag)
    • Migration (--m flag)
    • Policy (--p flag)
    • Resource (--r flag)
    • Controller (--c flag)
    • API Controller (--a flag)

    Example (custom bundle):

    php artisan make:bundle Product --n --m --p --r --c
    
    • --n forces Nova resource creation (if enabled in config).
    • --m, --p, --r, etc., override config defaults.
  • Customization: Modify config/muetze.php to set global defaults (e.g., disable migrations by default):

    'make-bundle' => [
        'migration' => false,
        // ... other flags
    ]
    
  • Integration Tips:

    • Use --r to generate a web resource (for Laravel UI) alongside the model.
    • Use --a to generate an API resource (for API-heavy projects).
    • Pair with make:auth or make:seeder for additional scaffolding.

Extending Functionality

  • Custom Commands: Extend the package by creating your own Artisan commands that reuse its logic (e.g., custom pivot table naming conventions). Example:

    php artisan make:command CustomPivotCommand
    

    Then integrate the pivot migration logic from Muetze\Commands\MakePivotTable.

  • Configuration Overrides: Override the published config to:

    • Change default namespaces (e.g., controller namespace).
    • Disable/enable features globally (e.g., always skip migrations).

Gotchas and Tips

Pitfalls

  1. Archived Package:

    • The package is archived (last release: 2021). Verify compatibility with your Laravel version (tested up to Laravel 8).
    • No active maintenance; fork or extend if critical bugs arise.
  2. Config Overrides:

    • Forgetting to publish the config (vendor:publish) means using hardcoded defaults.
    • Example: If nova-resource is false in config but you run make:bundle --n, it will fail silently.
  3. Pivot Table Naming:

    • The pivot table name is auto-generated as {Model1}{Model2}. Override in the migration if needed:
      public function up()
      {
          Schema::create('custom_user_role', function (Blueprint $table) { ... });
      }
      
  4. Policy Conflicts:

    • The --p flag creates a basic policy. Ensure it doesn’t conflict with existing policies (e.g., UserPolicy vs. PostPolicy).

Debugging Tips

  1. Command Errors:

    • Check if the model classes exist before running make:migration:pivot:
      php artisan make:migration:pivot NonExistentModel Role
      
      → Fails with Class not found (helpful for catching typos).
  2. Bundle Generation:

    • If make:bundle skips expected files, verify the config:
      php artisan config:get muetze.make-bundle
      
    • Run with --verbose to debug:
      php artisan make:bundle Post --verbose
      
  3. Namespace Issues:

    • If controllers/resources are generated in the wrong namespace, update config/muetze.php under 'namespaces'.

Extension Points

  1. Custom Stubs:

    • Override the package’s stub files (located in vendor/norman-huth/muetze/src/stubs) by publishing them:
      php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="stubs"
      
    • Modify model.stub, policy.stub, etc., to match your team’s conventions.
  2. Add New Features:

    • Extend the MakeBundle command to support additional scaffolding (e.g., factories, observers):
      // In a service provider:
      $this->app->extend('command.make.bundle', function ($command) {
          $command->addOption('factory', 'Create a factory', 'factory');
          return $command;
      });
      
  3. Testing:

    • Test pivot migrations with:
      php artisan migrate
      
    • Verify relationships work:
      $user->roles()->attach([1, 2]);
      
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
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