This commit is contained in:
@@ -81,6 +81,14 @@ class ProductController extends Controller
|
|||||||
'large_unit' => 'nullable|string|max:50',
|
'large_unit' => 'nullable|string|max:50',
|
||||||
'conversion_rate' => 'required_with:large_unit|nullable|numeric|min:0.0001',
|
'conversion_rate' => 'required_with:large_unit|nullable|numeric|min:0.0001',
|
||||||
'purchase_unit' => 'nullable|string|max:50',
|
'purchase_unit' => 'nullable|string|max:50',
|
||||||
|
], [
|
||||||
|
'name.required' => '商品名稱為必填',
|
||||||
|
'category_id.required' => '請選擇分類',
|
||||||
|
'category_id.exists' => '所選分類不存在',
|
||||||
|
'base_unit.required' => '基本庫存單位為必填',
|
||||||
|
'conversion_rate.required_with' => '填寫大單位時,換算率為必填',
|
||||||
|
'conversion_rate.numeric' => '換算率必須為數字',
|
||||||
|
'conversion_rate.min' => '換算率最小為 0.0001',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Auto-generate code
|
// Auto-generate code
|
||||||
@@ -109,7 +117,6 @@ class ProductController extends Controller
|
|||||||
'base_unit' => 'required|string|max:50',
|
'base_unit' => 'required|string|max:50',
|
||||||
'large_unit' => 'nullable|string|max:50',
|
'large_unit' => 'nullable|string|max:50',
|
||||||
'conversion_rate' => 'required_with:large_unit|nullable|numeric|min:0.0001',
|
'conversion_rate' => 'required_with:large_unit|nullable|numeric|min:0.0001',
|
||||||
'purchase_unit' => 'nullable|string|max:50',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$product->update($validated);
|
$product->update($validated);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?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('products', function (Blueprint $table) {
|
||||||
|
$table->decimal('conversion_rate', 10, 4)->nullable()->default(null)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('products', function (Blueprint $table) {
|
||||||
|
$table->decimal('conversion_rate', 10, 4)->nullable(false)->default(1)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user