invoiceninja/app/Http/Requests/Client/UploadClientRequest.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2021-02-15 21:52:50 +11:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-29 09:21:40 +11:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2021-02-15 21:52:50 +11:00
*
2021-06-16 16:58:16 +10:00
* @license https://www.elastic.co/licensing/elastic-license
2021-02-15 21:52:50 +11:00
*/
namespace App\Http\Requests\Client;
use App\Http\Requests\Request;
class UploadClientRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->can('edit', $this->client);
}
public function rules()
{
$rules = [];
2021-02-15 21:52:50 +11:00
2023-02-27 20:12:59 +11:00
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
2021-02-15 21:52:50 +11:00
return $rules;
2021-02-15 21:52:50 +11:00
}
}