2021-02-15 22:14:30 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2023-08-20 06:36:22 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2021-02-15 22:14:30 +01:00
|
|
|
*
|
2023-08-20 06:36:22 +02:00
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
2021-02-15 22:14:30 +01:00
|
|
|
*
|
2023-08-20 06:36:22 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-02-15 22:14:30 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-02-15 22:14:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Task;
|
|
|
|
|
|
|
|
use App\Http\Requests\Request;
|
|
|
|
|
|
|
|
class UploadTaskRequest extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize() : bool
|
|
|
|
{
|
2023-08-20 06:36:22 +02:00
|
|
|
/** @var \App\Models\User $user */
|
|
|
|
$user = auth()->user();
|
|
|
|
|
|
|
|
return $user->can('edit', $this->task);
|
2021-02-15 22:14:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
2023-08-20 06:36:22 +02:00
|
|
|
$rules = [
|
|
|
|
'documents' => 'bail|sometimes|file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000',
|
|
|
|
'is_public' => 'sometimes|boolean',
|
|
|
|
];
|
2021-02-15 22:14:30 +01:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
return $rules;
|
2021-02-15 22:14:30 +01:00
|
|
|
}
|
2023-08-20 06:36:22 +02:00
|
|
|
|
|
|
|
public function prepareForValidation()
|
|
|
|
{
|
|
|
|
$input = $this->all();
|
|
|
|
|
|
|
|
if(isset($input['is_public']))
|
|
|
|
$input['is_public'] = $this->toBoolean($input['is_public']);
|
|
|
|
|
|
|
|
$this->replace($input);
|
|
|
|
}
|
|
|
|
|
2021-02-15 22:14:30 +01:00
|
|
|
}
|