Update
parent
cc41bdde4f
commit
637a64ae73
|
|
@ -39,17 +39,6 @@ class RiceShrimpFlowController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(RiceShrimpFlowStoreRequest $request): RiceShrimpFlowResource
|
public function store(RiceShrimpFlowStoreRequest $request): RiceShrimpFlowResource
|
||||||
{
|
{
|
||||||
$riceShrimpFlowExists = RiceShrimpFlow::query()
|
|
||||||
->where('year', $request->input('year'))
|
|
||||||
->where('quarter', $request->input('quarter'))
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($riceShrimpFlowExists) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'quarter' => ['季度已经存在'],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
$riceShrimpFlow = new RiceShrimpFlow(
|
$riceShrimpFlow = new RiceShrimpFlow(
|
||||||
|
|
@ -84,6 +73,8 @@ class RiceShrimpFlowController extends Controller
|
||||||
$riceShrimpFlow = RiceShrimpFlow::findOrFail($id);
|
$riceShrimpFlow = RiceShrimpFlow::findOrFail($id);
|
||||||
|
|
||||||
foreach ([
|
foreach ([
|
||||||
|
'year',
|
||||||
|
'quarter',
|
||||||
'area',
|
'area',
|
||||||
'sales',
|
'sales',
|
||||||
] as $key) {
|
] as $key) {
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,6 @@ class RiceShrimpIndustryController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(RiceShrimpIndustryStoreRequest $request): RiceShrimpIndustryResource
|
public function store(RiceShrimpIndustryStoreRequest $request): RiceShrimpIndustryResource
|
||||||
{
|
{
|
||||||
$riceShrimpIndustryExists = RiceShrimpIndustry::query()
|
|
||||||
->where('year', $request->input('year'))
|
|
||||||
->where('quarter', $request->input('quarter'))
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($riceShrimpIndustryExists) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'quarter' => ['季度已经存在'],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
$riceShrimpIndustry = new RiceShrimpIndustry(
|
$riceShrimpIndustry = new RiceShrimpIndustry(
|
||||||
|
|
@ -85,6 +74,8 @@ class RiceShrimpIndustryController extends Controller
|
||||||
$riceShrimpIndustry = RiceShrimpIndustry::findOrFail($id);
|
$riceShrimpIndustry = RiceShrimpIndustry::findOrFail($id);
|
||||||
|
|
||||||
foreach ([
|
foreach ([
|
||||||
|
'year',
|
||||||
|
'quarter',
|
||||||
'area',
|
'area',
|
||||||
'product_output',
|
'product_output',
|
||||||
'product_value',
|
'product_value',
|
||||||
|
|
|
||||||
|
|
@ -40,17 +40,6 @@ class RiceShrimpPriceController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(RiceShrimpPriceStoreRequest $request): RiceShrimpPriceResource
|
public function store(RiceShrimpPriceStoreRequest $request): RiceShrimpPriceResource
|
||||||
{
|
{
|
||||||
$riceShrimpPriceExists = RiceShrimpPrice::query()
|
|
||||||
->where('year', $request->input('year'))
|
|
||||||
->where('quarter', $request->input('quarter'))
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($riceShrimpPriceExists) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'quarter' => ['季度已经存在'],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
$riceShrimpPrice = RiceShrimpPrice::create(
|
$riceShrimpPrice = RiceShrimpPrice::create(
|
||||||
|
|
@ -82,7 +71,15 @@ class RiceShrimpPriceController extends Controller
|
||||||
{
|
{
|
||||||
$riceShrimpPrice = RiceShrimpPrice::findOrFail($id);
|
$riceShrimpPrice = RiceShrimpPrice::findOrFail($id);
|
||||||
|
|
||||||
$riceShrimpPrice->price = $request->input('price');
|
foreach ([
|
||||||
|
'year',
|
||||||
|
'quarter',
|
||||||
|
'price',
|
||||||
|
] as $key) {
|
||||||
|
if ($request->filled($key)) {
|
||||||
|
$riceShrimpPrice->{$key} = $request->input($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($riceShrimpPrice->isDirty()) {
|
if ($riceShrimpPrice->isDirty()) {
|
||||||
$riceShrimpPrice->updated_by = $request->user()->id;
|
$riceShrimpPrice->updated_by = $request->user()->id;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Requestes;
|
namespace App\Http\Requestes;
|
||||||
|
|
||||||
|
use App\Rules\Quarter;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,7 @@ class RiceShrimpFlowStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'year' => ['required', 'int'],
|
'year' => ['required', 'int'],
|
||||||
'quarter' => ['required', 'int', Rule::in([1, 2, 3, 4])],
|
'quarter' => ['required', new Quarter()],
|
||||||
'area' => ['required', 'int'],
|
'area' => ['required', 'int'],
|
||||||
'sales' => ['required', 'int', 'min:0'],
|
'sales' => ['required', 'int', 'min:0'],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Requestes;
|
namespace App\Http\Requestes;
|
||||||
|
|
||||||
|
use App\Rules\Quarter;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class RiceShrimpFlowUpdateRequest extends FormRequest
|
class RiceShrimpFlowUpdateRequest extends FormRequest
|
||||||
|
|
@ -14,6 +15,8 @@ class RiceShrimpFlowUpdateRequest extends FormRequest
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'year' => ['filled', 'int'],
|
||||||
|
'quarter' => ['filled', new Quarter()],
|
||||||
'area' => ['filled', 'int'],
|
'area' => ['filled', 'int'],
|
||||||
'sales' => ['filled', 'int', 'min:0'],
|
'sales' => ['filled', 'int', 'min:0'],
|
||||||
];
|
];
|
||||||
|
|
@ -22,6 +25,8 @@ class RiceShrimpFlowUpdateRequest extends FormRequest
|
||||||
public function attributes()
|
public function attributes()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'year' => '年份',
|
||||||
|
'quarter' => '季度',
|
||||||
'area' => '地区',
|
'area' => '地区',
|
||||||
'sales' => '销量',
|
'sales' => '销量',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Requestes;
|
namespace App\Http\Requestes;
|
||||||
|
|
||||||
|
use App\Rules\Quarter;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,7 @@ class RiceShrimpIndustryStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'year' => ['required', 'int'],
|
'year' => ['required', 'int'],
|
||||||
'quarter' => ['required', 'int', Rule::in([1, 2, 3, 4])],
|
'quarter' => ['required', new Quarter()],
|
||||||
'area' => ['required', 'int', 'min:0'],
|
'area' => ['required', 'int', 'min:0'],
|
||||||
'product_output' => ['required', 'int', 'min:0'],
|
'product_output' => ['required', 'int', 'min:0'],
|
||||||
'product_value' => ['required', 'int', 'min:0'],
|
'product_value' => ['required', 'int', 'min:0'],
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Requestes;
|
namespace App\Http\Requestes;
|
||||||
|
|
||||||
|
use App\Rules\Quarter;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -15,6 +16,8 @@ class RiceShrimpIndustryUpdateRequest extends FormRequest
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'year' => ['filled', 'int'],
|
||||||
|
'quarter' => ['filled', new Quarter()],
|
||||||
'area' => ['filled', 'int', 'min:0'],
|
'area' => ['filled', 'int', 'min:0'],
|
||||||
'product_output' => ['filled', 'int', 'min:0'],
|
'product_output' => ['filled', 'int', 'min:0'],
|
||||||
'product_value' => ['filled', 'int', 'min:0'],
|
'product_value' => ['filled', 'int', 'min:0'],
|
||||||
|
|
@ -24,6 +27,8 @@ class RiceShrimpIndustryUpdateRequest extends FormRequest
|
||||||
public function attributes()
|
public function attributes()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'year' => '年份',
|
||||||
|
'quarter' => '季度',
|
||||||
'area' => '面积',
|
'area' => '面积',
|
||||||
'product_output' => '产量',
|
'product_output' => '产量',
|
||||||
'product_value' => '产值',
|
'product_value' => '产值',
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Requestes;
|
namespace App\Http\Requestes;
|
||||||
|
|
||||||
|
use App\Rules\Quarter;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,7 @@ class RiceShrimpPriceStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'year' => ['required', 'int'],
|
'year' => ['required', 'int'],
|
||||||
'quarter' => ['required', 'int', Rule::in([1, 2, 3, 4])],
|
'quarter' => ['required', new Quarter()],
|
||||||
'price' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
'price' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Requestes;
|
namespace App\Http\Requestes;
|
||||||
|
|
||||||
|
use App\Rules\Quarter;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -15,13 +16,17 @@ class RiceShrimpPriceUpdateRequest extends FormRequest
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'price' => ['required', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
'year' => ['filled', 'int'],
|
||||||
|
'quarter' => ['filled', new Quarter()],
|
||||||
|
'price' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attributes()
|
public function attributes()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'year' => '年份',
|
||||||
|
'quarter' => '季度',
|
||||||
'price' => '价格',
|
'price' => '价格',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue