baks-dev/manufacture-part-application
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.
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
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(),
]);
Batch Process Management
ManufacturePartApplication::create() to initialize a production batch.ManufacturePartApplication::find($id)->updateStatus('in_progress').ManufacturePartApplication::complete($id, ['yield' => 95]).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',
],
];
API Integration Expose endpoints via Laravel routes:
Route::apiResource('manufacture-applications', \BaksDev\ManufacturePartApplication\Http\Controllers\ManufacturePartApplicationController::class);
Customize responses by overriding controller methods.
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);
});
ManufacturePartApplicationServiceProvider:
$this->app->bind(
\BaksDev\ManufacturePartApplication\Repositories\ManufacturePartApplicationRepository::class,
\App\Repositories\CustomManufacturePartApplicationRepository::class
);
--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);
Migration Conflicts
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.php artisan migrate:status to check for pending migrations.Facade vs. Direct Service Usage
use BaksDev\ManufacturePartApplication\Services\ManufacturePartApplicationService;
public function __construct(private ManufacturePartApplicationService $service) {}
Translation Strings
baks-dev/core for translations. Ensure your config/app.php includes:
'providers' => [
BaksDev\Core\Translation\TranslationServiceProvider::class,
],
resources/lang/en/manufacture_part_application.php.Event Dispatching
config/app.php:
'providers' => [
BaksDev\ManufacturePartApplication\ManufacturePartApplicationServiceProvider::class,
],
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.
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,
],
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();
});
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,
]);
baks:assets:install command may fail if storage/app/public isn’t writable. Ensure permissions:
chmod -R 775 storage/
config/doctrine.php:
'orm' => [
'metadata_cache' => null,
],
This prevents conflicts with Laravel’s Eloquent cache.How can I help you explore Laravel packages today?