42 lines
958 B
PHP
42 lines
958 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\Session;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class AccountSupplierAdd extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::allows('wholesaler');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
Session::put('supplier_update',true);
|
|
|
|
return [
|
|
'supplier_ref'=> [
|
|
'required',
|
|
'string',
|
|
'min:2',
|
|
Rule::unique('account_supplier')
|
|
->where(fn($query)=>$query
|
|
->where('account_id',request()->get('account_id')))
|
|
->where('supplier_id',request()->get('supplier_id')),
|
|
],
|
|
'supplier_id'=>'required|exists:suppliers,id',
|
|
];
|
|
}
|
|
} |