1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/Requests/TaskRequest.php

32 lines
766 B
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Http\Requests;
2016-05-01 14:04:55 +02:00
use App\Models\Client;
2017-01-30 17:05:31 +01:00
class TaskRequest extends EntityRequest
{
2016-05-01 14:04:55 +02:00
protected $entityType = ENTITY_TASK;
public function sanitize()
{
$input = $this->all();
// check if we're creating a new project
if ($this->project_id == '-1'
&& trim($this->project_name)
&& $this->user()->can('create', ENTITY_PROJECT))
{
$project = app('App\Ninja\Repositories\ProjectRepository')->save([
'name' => trim($this->project_name),
'client_id' => Client::getPrivateId($this->client),
]);
$input['project_id'] = $project->public_id;
}
$this->replace($input);
return $this->all();
}
2017-01-30 17:05:31 +01:00
}