Move user suppliers to account suppliers
This commit is contained in:
42
app/Http/Requests/AccountSupplierAdd.php
Normal file
42
app/Http/Requests/AccountSupplierAdd.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user