Fixes for service change, validation added for date and product_id
This commit is contained in:
45
app/Http/Requests/ServiceChange.php
Normal file
45
app/Http/Requests/ServiceChange.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* Editing Suppliers
|
||||
*/
|
||||
class ServiceChange extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Gate::allows('view',$this->route('o'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'change_date'=> [
|
||||
'required',
|
||||
'date',
|
||||
'after:today',
|
||||
],
|
||||
'product_id' => [
|
||||
'required',
|
||||
'exists:products,id',
|
||||
Rule::notIn([request()->route('o')->product_id]),
|
||||
],
|
||||
'notes' => 'nullable|min:5',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user