erp/app/Http/Requests/GoodsRequest.php

43 lines
826 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class GoodsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'type_id' => ['required', 'integer', 'exists:goods_types,id'],
];
}
public function arrayRules($arrayName)
{
$arrayRules = [];
$rules = $this->rules();
foreach ($rules as $key => $val) {
$arrayRules[$arrayName . $key] = $val;
}
return $arrayRules;
}
}