1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/Http/Requests/Expense/UploadExpenseRequest.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2021-02-15 12:07:47 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2021-02-15 12:07:47 +01:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-02-15 12:07:47 +01:00
*/
namespace App\Http\Requests\Expense;
use App\Http\Requests\Request;
class UploadExpenseRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->can('edit', $this->expense);
}
public function rules()
{
$rules = [];
2021-02-15 12:07:47 +01:00
2023-02-27 10:12:59 +01: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 12:07:47 +01:00
return $rules;
2021-02-15 12:07:47 +01:00
}
}