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

Manufacture Part Application Laravel Package

baks-dev/manufacture-part-application

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Run composer require baks-dev/manufacture-part-application in your Laravel project. Ensure your project meets the PHP 8.4+ requirement and has baks-dev/core and baks-dev/manufacture-part installed.

  2. Publish Assets & Migrations Execute:

    php artisan vendor:publish --provider="BaksDev\ManufacturePartApplication\ManufacturePartApplicationServiceProvider" --tag="config"
    php artisan vendor:publish --provider="BaksDev\ManufacturePartApplication\ManufacturePartApplicationServiceProvider" --tag="migrations"
    

    Then run migrations:

    php artisan migrate
    
  3. First Use Case Trigger the asset installation (if needed):

    php artisan baks:assets:install
    

    Use the ManufacturePartApplication facade to create a production batch process:

    use BaksDev\ManufacturePartApplication\Facades\ManufacturePartApplication;
    
    $application = ManufacturePartApplication::create([
        'part_id' => 123, // ID of the manufactured part
        'quantity' => 100,
        'start_date' => now(),
    ]);
    

Implementation Patterns

Core Workflows

  1. Batch Process Management

    • Use ManufacturePartApplication::create() to initialize a production batch.
    • Track progress via ManufacturePartApplication::find($id)->updateStatus('in_progress').
    • Finalize with ManufacturePartApplication::complete($id, ['yield' => 95]).
  2. Event-Driven Extensions Listen to ManufacturePartApplicationCreated and ManufacturePartApplicationCompleted events:

    event(new ManufacturePartApplicationCreated($application));
    

    Register listeners in EventServiceProvider:

    protected $listen = [
        'BaksDev\ManufacturePartApplication\Events\ManufacturePartApplicationCreated' => [
            'App\Listeners\NotifyProductionTeam',
        ],
    ];
    
  3. API Integration Expose endpoints via Laravel routes:

    Route::apiResource('manufacture-applications', \BaksDev\ManufacturePartApplication\Http\Controllers\ManufacturePartApplicationController::class);
    

    Customize responses by overriding controller methods.

  4. Validation & Rules Extend validation logic in app/Providers/AppServiceProvider:

    use BaksDev\ManufacturePartApplication\Rules\ValidPartQuantity;
    
    Valid::extend('valid_quantity', function ($attribute, $value, $parameters, $validator) {
        return (new ValidPartQuantity())->passes($value, $parameters);
    });
    

Integration Tips

  • Dependency Injection Bind custom repositories or services in ManufacturePartApplicationServiceProvider:
    $this->app->bind(
        \BaksDev\ManufacturePartApplication\Repositories\ManufacturePartApplicationRepository::class,
        \App\Repositories\CustomManufacturePartApplicationRepository::class
    );
    
  • Testing Use the --group=manufacture-part-application flag:
    php artisan test --group=manufacture-part-application
    
    Mock the facade in tests:
    $this->mock(ManufacturePartApplication::class)->shouldReceive('create')->andReturn($mockApplication);
    

Gotchas and Tips

Pitfalls

  1. Migration Conflicts

    • If doctrine:migrations:diff fails, manually resolve schema conflicts by comparing the published migrations (database/migrations/YYYY_MM_XX_*_manufacture_part_application.php) with your existing migrations.
    • Tip: Use php artisan migrate:status to check for pending migrations.
  2. Facade vs. Direct Service Usage

    • Avoid overusing the facade in loops or complex logic. Inject the service directly:
      use BaksDev\ManufacturePartApplication\Services\ManufacturePartApplicationService;
      
      public function __construct(private ManufacturePartApplicationService $service) {}
      
  3. Translation Strings

    • The package uses baks-dev/core for translations. Ensure your config/app.php includes:
      'providers' => [
          BaksDev\Core\Translation\TranslationServiceProvider::class,
      ],
      
    • Tip: Extend translations in resources/lang/en/manufacture_part_application.php.
  4. Event Dispatching

    • Events may not fire if the service provider isn’t registered. Verify in config/app.php:
      'providers' => [
          BaksDev\ManufacturePartApplication\ManufacturePartApplicationServiceProvider::class,
      ],
      

Debugging

  • Log Entries Enable debug mode in config/manufacture_part_application.php:

    'debug' => env('APP_DEBUG', false),
    

    Logs will appear in storage/logs/laravel.log.

  • Query Logging Add to .env:

    DB_DEBUG=true
    

    Queries will log to the console during development.

Extension Points

  1. Custom Fields Extend the ManufacturePartApplication model:

    use BaksDev\ManufacturePartApplication\Models\ManufacturePartApplication as BaseModel;
    
    class CustomManufacturePartApplication extends BaseModel
    {
        protected $casts = [
            'custom_field' => 'array',
        ];
    }
    

    Update the config to use your model:

    'models' => [
        'manufacture_part_application' => \App\Models\CustomManufacturePartApplication::class,
    ],
    
  2. API Resources Override the default resource:

    use BaksDev\ManufacturePartApplication\Http\Resources\ManufacturePartApplicationResource;
    
    class CustomManufacturePartApplicationResource extends ManufacturePartApplicationResource
    {
        public function toArray($request)
        {
            $array = parent::toArray($request);
            $array['custom_field'] = $this->resource->custom_field;
            return $array;
        }
    }
    

    Bind it in AppServiceProvider:

    ManufacturePartApplicationResource::macro('custom', function () {
        return new CustomManufacturePartApplicationResource();
    });
    
  3. Console Commands Extend existing commands or create new ones:

    use BaksDev\ManufacturePartApplication\Console\Commands\GenerateReportCommand;
    
    class CustomReportCommand extends GenerateReportCommand
    {
        protected $signature = 'baks:custom-report {--part=*}';
        // ...
    }
    

    Register in ManufacturePartApplicationServiceProvider:

    $this->commands([
        \App\Console\Commands\CustomReportCommand::class,
    ]);
    

Configuration Quirks

  • Asset Installation The baks:assets:install command may fail if storage/app/public isn’t writable. Ensure permissions:
    chmod -R 775 storage/
    
  • Doctrine ORM If using Eloquent, disable Doctrine’s metadata cache in config/doctrine.php:
    'orm' => [
        'metadata_cache' => null,
    ],
    
    This prevents conflicts with Laravel’s Eloquent cache.
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.
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
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium