invoiceninja/app/Http/Requests/TaskRequest.php

29 lines
699 B
PHP
Raw Normal View History

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