Auto-deduct spice inventory when batch is created/updated/deleted
Deploy / deploy (push) Successful in 14s
Deploy / deploy (push) Successful in 14s
- Add size_id, units_produced, quantity_g to batches table - quantity_g auto-calculated from units × packing size on save - Batch model deducts spice quantities on create, reverses on delete, recalculates on update when relevant fields change - Batch form shows live total weight preview - Chargen table shows units + grams produced Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e93aaa7d8
commit
a34bb29620
4 files changed
+163
-1
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('batches', function (Blueprint $table) {
|
||||
$table->foreignId('size_id')->nullable()->after('product_id')
|
||||
->constrained('products_sizes')->nullOnDelete();
|
||||
$table->unsignedInteger('units_produced')->nullable()->after('size_id');
|
||||
$table->decimal('quantity_g', 10, 2)->nullable()->after('units_produced');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('batches', function (Blueprint $table) {
|
||||
$table->dropForeign(['size_id']);
|
||||
$table->dropColumn(['size_id', 'units_produced', 'quantity_g']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user