mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 04:04:47 -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.
|
* Determine if the user is authorized to make this request.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @method static \Illuminate\Contracts\Auth\Authenticatable|null user()
|
||||||
*/
|
*/
|
||||||
public function authorize() : bool
|
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()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
/** @var \App\User|null $user */
|
||||||
/* Ensure we have a client name, and that all emails are unique*/
|
$user = auth()->user();
|
||||||
//$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();
|
|
||||||
|
|
||||||
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
||||||
|
|
||||||
if (isset($this->number)) {
|
if (isset($this->number))
|
||||||
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
|
$rules['number'] = Rule::unique('vendors')->where('company_id', $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';
|
|
||||||
|
|
||||||
|
$rules['currency_id'] = 'bail|required|exists:currencies,id';
|
||||||
|
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepareForValidation()
|
public function prepareForValidation()
|
||||||
{
|
{
|
||||||
|
/** @var \App\User|null $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
if(!array_key_exists('currency_id', $input)){
|
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);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
@ -71,8 +70,6 @@ class StoreVendorRequest extends Request
|
|||||||
public function messages()
|
public function messages()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// 'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
|
||||||
//'required' => trans('validation.required', ['attribute' => 'email']),
|
|
||||||
'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
|
'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
/**
|
/**
|
||||||
* Returns the current company.
|
* Returns the current company.
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return App\Models\Company $company
|
||||||
*/
|
*/
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user