mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add doc block definitions
This commit is contained in:
parent
454359d253
commit
3998cc9d10
33
app/Http/Requests/Vendor/StoreVendorRequest.php
vendored
33
app/Http/Requests/Vendor/StoreVendorRequest.php
vendored
@ -25,42 +25,41 @@ class StoreVendorRequest extends Request
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
* @method static \Illuminate\Contracts\Auth\Authenticatable|null user()
|
||||
*/
|
||||
public function authorize() : bool
|
||||
{
|
||||
return auth()->user()->can('create', Vendor::class);
|
||||
/** @var \App\User|null $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('create', Vendor::class);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
/* Ensure we have a client name, and that all emails are unique*/
|
||||
//$rules['name'] = 'required|min:1';
|
||||
// $rules['id_number'] = 'unique:vendors,id_number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
|
||||
//$rules['settings'] = new ValidVendorGroupSettingsRule();
|
||||
/** @var \App\User|null $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
||||
|
||||
if (isset($this->number)) {
|
||||
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
|
||||
}
|
||||
|
||||
// if (isset($this->id_number)) {
|
||||
// $rules['id_number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
|
||||
// }
|
||||
|
||||
$rules['currency_id'] = 'bail|required|exists:currencies,id';
|
||||
if (isset($this->number))
|
||||
$rules['number'] = Rule::unique('vendors')->where('company_id', $user->company()->id);
|
||||
|
||||
$rules['currency_id'] = 'bail|required|exists:currencies,id';
|
||||
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
/** @var \App\User|null $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
if(!array_key_exists('currency_id', $input)){
|
||||
$input['currency_id'] = auth()->user()->company()->settings->currency_id;
|
||||
$input['currency_id'] = $user->company()->settings->currency_id;
|
||||
}
|
||||
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
@ -71,8 +70,6 @@ class StoreVendorRequest extends Request
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
// 'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
||||
//'required' => trans('validation.required', ['attribute' => 'email']),
|
||||
'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
|
||||
];
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
/**
|
||||
* Returns the current company.
|
||||
*
|
||||
* @return Collection
|
||||
* @return App\Models\Company $company
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user