feat(food): implement FoodController, FoodService, and related resources for managing food items and variants
refactor(catalog): add description and price fields to variants and update related resources feat(migration): add commercial overrides to variants with description and price fields test(food): add tests for FoodController and ensure correct seeding of food items and variants
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('variantes', function (Blueprint $table): void {
|
||||
$table->text('descripcion')->nullable()->after('inventory_id');
|
||||
$table->decimal('precio', 10, 2)->nullable()->after('descripcion');
|
||||
});
|
||||
|
||||
DB::table('variantes')->orderBy('id')->each(function (object $variant): void {
|
||||
$price = DB::table('catalog_items')
|
||||
->where('id', $variant->catalog_item_id)
|
||||
->value('precio');
|
||||
|
||||
DB::table('variantes')->where('id', $variant->id)->update([
|
||||
'precio' => $price,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('variantes', function (Blueprint $table): void {
|
||||
$table->dropColumn(['descripcion', 'precio']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user