Update
parent
33c5dddc03
commit
5756e59ab7
|
|
@ -17,12 +17,12 @@ class MaterielStoreRequest extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'year' => ['required', 'int'],
|
||||
'quarter' => ['required', new Quarter()],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'type' => ['required', new Enum(MaterielType::class)],
|
||||
'lowest_price' => ['required', 'int'],
|
||||
'highest_price' => ['required', 'int', 'gte:lowest_price'],
|
||||
'year' => ['bail', 'required', 'int'],
|
||||
'quarter' => ['bail', 'required', new Quarter()],
|
||||
'name' => ['bail', 'required', 'string', 'max:255'],
|
||||
'type' => ['bail', 'required', new Enum(MaterielType::class)],
|
||||
'lowest_price' => ['bail', 'required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'highest_price' => ['bail', 'required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/', 'gte:lowest_price'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class MaterielUpdateRequest extends FormRequest
|
|||
'quarter' => ['filled', new Quarter()],
|
||||
'name' => ['filled', 'string', 'max:255'],
|
||||
'type' => ['filled', new Enum(MaterielType::class)],
|
||||
'lowest_price' => ['filled', 'int'],
|
||||
'highest_price' => ['filled', 'int', 'gte:lowest_price'],
|
||||
'lowest_price' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'highest_price' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/', 'gte:lowest_price'],
|
||||
'unit' => ['filled', 'string'],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class RiceShrimpFlowStoreRequest extends FormRequest
|
|||
'year' => ['required', 'int'],
|
||||
'quarter' => ['required', new Quarter()],
|
||||
'area' => ['required', 'string'],
|
||||
'sales' => ['required', 'int', 'min:0'],
|
||||
'sales' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'unit' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class RiceShrimpFlowUpdateRequest extends FormRequest
|
|||
'year' => ['filled', 'int'],
|
||||
'quarter' => ['filled', new Quarter()],
|
||||
'area' => ['filled', 'string'],
|
||||
'sales' => ['filled', 'int', 'min:0'],
|
||||
'sales' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'unit' => ['filled', 'string'],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ class RiceShrimpIndustryStoreRequest extends FormRequest
|
|||
return [
|
||||
'year' => ['required', 'int'],
|
||||
'quarter' => ['required', new Quarter()],
|
||||
'area' => ['required', 'int', 'min:0'],
|
||||
'area' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'area_unit' => ['required', 'string'],
|
||||
'product_output' => ['required', 'int', 'min:0'],
|
||||
'product_output' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'product_output_unit' => ['required', 'string'],
|
||||
'product_value' => ['required', 'int', 'min:0'],
|
||||
'product_value' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'product_value_unit' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ class RiceShrimpIndustryUpdateRequest extends FormRequest
|
|||
return [
|
||||
'year' => ['filled', 'int'],
|
||||
'quarter' => ['filled', new Quarter()],
|
||||
'area' => ['filled', 'int', 'min:0'],
|
||||
'area' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'area_unit' => ['filled', 'string'],
|
||||
'product_output' => ['filled', 'int', 'min:0'],
|
||||
'product_output' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'product_output_unit' => ['filled', 'string'],
|
||||
'product_value' => ['filled', 'int', 'min:0'],
|
||||
'product_value' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||
'product_value_unit' => ['filled', 'string'],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ class MaterielResource extends JsonResource
|
|||
'type' => $this->type,
|
||||
'year' => $this->year,
|
||||
'quarter' => $this->quarter,
|
||||
'lowest_price' => $this->lowest_price,
|
||||
'highest_price' => $this->highest_price,
|
||||
'lowest_price' => trim_trailing_zero($this->lowest_price),
|
||||
'highest_price' => trim_trailing_zero($this->highest_price),
|
||||
'unit' => $this->unit,
|
||||
'created_by' => AdminUserResource::make($this->whenLoaded('createdBy')),
|
||||
'updated_by' => AdminUserResource::make($this->whenLoaded('updatedBy')),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class RiceShrimpFlowResource extends JsonResource
|
|||
'year' => $this->year,
|
||||
'quarter' => $this->quarter,
|
||||
'area' => $this->area,
|
||||
'sales' => $this->sales,
|
||||
'sales' => trim_trailing_zero($this->sales),
|
||||
'unit' => $this->unit,
|
||||
'created_by' => AdminUserResource::make($this->whenLoaded('createdBy')),
|
||||
'updated_by' => AdminUserResource::make($this->whenLoaded('updatedBy')),
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ class RiceShrimpIndustryResource extends JsonResource
|
|||
'id' => $this->id,
|
||||
'year' => $this->year,
|
||||
'quarter' => $this->quarter,
|
||||
'area' => $this->area,
|
||||
'area' => trim_trailing_zero($this->area),
|
||||
'area_unit' => $this->area_unit,
|
||||
'product_output' => $this->product_output,
|
||||
'product_output' => trim_trailing_zero($this->product_output),
|
||||
'product_output_unit' => $this->product_output_unit,
|
||||
'product_value' => $this->product_value,
|
||||
'product_value' => trim_trailing_zero($this->product_value),
|
||||
'product_value_unit' => $this->product_value_unit,
|
||||
'created_by' => AdminUserResource::make($this->whenLoaded('createdBy')),
|
||||
'updated_by' => AdminUserResource::make($this->whenLoaded('updatedBy')),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
function trim_trailing_zero($var)
|
||||
{
|
||||
if (is_numeric($var) && strpos($var, '.') !== false) {
|
||||
$var = rtrim(rtrim($var, '0'), '.');
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
|
@ -22,6 +22,9 @@
|
|||
"spatie/laravel-ignition": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->integer('year')->comment('年');
|
||||
$table->tinyInteger('quarter')->comment('季度');
|
||||
$table->unsignedBigInteger('area')->comment('面积');
|
||||
$table->unsignedDecimal('area', 18, 2)->comment('面积');
|
||||
$table->string('area_unit')->comment('面积单位');
|
||||
$table->unsignedBigInteger('product_output')->comment('产量');
|
||||
$table->unsignedDecimal('product_output', 18, 2)->comment('产量');
|
||||
$table->string('product_output_unit')->comment('产量单位');
|
||||
$table->unsignedBigInteger('product_value')->comment('产值');
|
||||
$table->unsignedDecimal('product_value', 18, 2)->comment('产值');
|
||||
$table->string('product_value_unit')->comment('产值单位');
|
||||
$table->unsignedBigInteger('created_by')->comment('创建人ID');
|
||||
$table->unsignedBigInteger('updated_by')->comment('修改人ID');
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ return new class extends Migration
|
|||
$table->integer('year')->comment('年');
|
||||
$table->tinyInteger('quarter')->comment('季度');
|
||||
$table->string('area')->comment('地区');
|
||||
$table->unsignedBigInteger('sales')->comment('销量');
|
||||
$table->unsignedDecimal('sales', 18, 2)->comment('销量');
|
||||
$table->string('unit')->comment('单位');
|
||||
$table->unsignedBigInteger('created_by')->comment('创建人ID');
|
||||
$table->unsignedBigInteger('updated_by')->comment('修改人ID');
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ return new class extends Migration
|
|||
$table->tinyInteger('type')->comment('类型: 1 饲料, 2 肥料');
|
||||
$table->integer('year')->comment('年');
|
||||
$table->tinyInteger('quarter')->comment('季度');
|
||||
$table->unsignedBigInteger('lowest_price')->comment('最低价格');
|
||||
$table->unsignedBigInteger('highest_price')->comment('最低价格');
|
||||
$table->unsignedDecimal('lowest_price', 18, 2)->comment('最低价格');
|
||||
$table->unsignedDecimal('highest_price', 18, 2)->comment('最低价格');
|
||||
$table->string('unit')->comment('单位');
|
||||
$table->unsignedBigInteger('created_by')->comment('创建人ID');
|
||||
$table->unsignedBigInteger('updated_by')->comment('修改人ID');
|
||||
|
|
|
|||
Loading…
Reference in New Issue