- Inco products servings are nullable and are now strings - Inco products servings type are nullable
This commit is contained in:
parent
180a5d9f55
commit
8bab835d61
3 changed files with 46 additions and 3 deletions
|
|
@ -63,14 +63,16 @@ final class DefaultProductType extends BaseEnumRoutable
|
|||
],
|
||||
'servings' => [
|
||||
'label' => 'Portions',
|
||||
'inputType' => InputType::number(),
|
||||
'inputType' => InputType::string(),
|
||||
'value' => '',
|
||||
'validate' => 'numeric|min:0'
|
||||
'required' => false,
|
||||
'validate' => 'nullable|string|max:35'
|
||||
],
|
||||
'servings_type' => [
|
||||
'label' => 'Type de portions',
|
||||
'inputType' => InputType::string(),
|
||||
'value' => '',
|
||||
'required' => false,
|
||||
'validate' => 'nullable|string|max:150'
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Product\DefaultProductType;
|
||||
use App\Models\Merchandise\Product;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ChangeIncoServingsInputTypeOnOrders extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Product::query()->where('type', DefaultProductType::inco())->each(function (Product $product) {
|
||||
$data = $product->data;
|
||||
$value = $data['servings']['value'];
|
||||
$valueSt = $data['servings_type']['value'];
|
||||
|
||||
$data['servings'] = DefaultProductType::incoInputs()['servings'];
|
||||
$data['servings_type'] = DefaultProductType::incoInputs()['servings_type'];
|
||||
|
||||
$data['servings']['value'] = strval($value);
|
||||
$data['servings_type']['value'] = strval($valueSt);
|
||||
|
||||
$product->data = $data;
|
||||
$product->saveQuietly();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Won't undo this.
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit ca1385e4cac559380e326b714d4c0d7096873020
|
||||
Subproject commit 74b13d406df2c37ee2e77056615db53f019dd736
|
||||
Loading…
Add table
Reference in a new issue