1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Requests/Project/UpdateProjectRequest.php
2020-10-29 22:01:37 +11:00

50 lines
1.1 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\Project;
use App\Http\Requests\Request;
use App\Models\Project;
use App\Utils\Traits\ChecksEntityStatus;
class UpdateProjectRequest extends Request
{
use ChecksEntityStatus;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->can('edit', $this->project);
}
public function rules()
{
$rules = [];
if ($this->input('number')) {
$rules['number'] = 'unique:projects,number,'.$this->id.',id,company_id,'.$this->project->company_id;
}
return $this->globalRules($rules);
}
protected function prepareForValidation()
{
$input = $this->decodePrimaryKeys($this->all());
$this->replace($input);
}
}