osb/app/Http/Requests/AccountSupplierAdd.php
Deon George cb9be6534f
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
Move user suppliers to account suppliers
2024-07-23 22:17:09 +10:00

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