osb/app/Http/Requests/ServiceChange.php

45 lines
780 B
PHP
Raw Normal View History

<?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',
];
}
}