Support creating inline vendors and categories

This commit is contained in:
Hillel Coren 2017-03-02 19:47:40 +02:00
parent 595a8a5aed
commit 2135d7c973
2 changed files with 12 additions and 3 deletions

View File

@ -24,7 +24,10 @@ class ExpenseRequest extends EntityRequest
{ {
$input = $this->all(); $input = $this->all();
if ($this->expense_category_id == '-1' && $this->user()->can('create', ENTITY_EXPENSE_CATEGORY)) { if ($this->expense_category_id == '-1'
&& trim($this->expense_category_name)
&& $this->user()->can('create', ENTITY_EXPENSE_CATEGORY))
{
$category = app('App\Ninja\Repositories\ExpenseCategoryRepository')->save([ $category = app('App\Ninja\Repositories\ExpenseCategoryRepository')->save([
'name' => $this->expense_category_name, 'name' => $this->expense_category_name,
]); ]);
@ -33,7 +36,10 @@ class ExpenseRequest extends EntityRequest
$input['expense_category_id'] = ExpenseCategory::getPrivateId($this->expense_category_id); $input['expense_category_id'] = ExpenseCategory::getPrivateId($this->expense_category_id);
} }
if ($this->vendor_id == '-1' && $this->user()->can('create', ENTITY_VENDOR)) { if ($this->vendor_id == '-1'
&& trim($this->vendor_name)
&& $this->user()->can('create', ENTITY_VENDOR))
{
$vendor = app('App\Ninja\Repositories\VendorRepository')->save([ $vendor = app('App\Ninja\Repositories\VendorRepository')->save([
'name' => $this->vendor_name, 'name' => $this->vendor_name,
]); ]);

View File

@ -13,7 +13,10 @@ class TaskRequest extends EntityRequest
$input = $this->all(); $input = $this->all();
// check if we're creating a new project // check if we're creating a new project
if ($this->project_id == '-1' && $this->user()->can('create', ENTITY_PROJECT)) { if ($this->project_id == '-1'
&& trim($this->project_name)
&& $this->user()->can('create', ENTITY_PROJECT))
{
$project = app('App\Ninja\Repositories\ProjectRepository')->save([ $project = app('App\Ninja\Repositories\ProjectRepository')->save([
'name' => $this->project_name, 'name' => $this->project_name,
'client_id' => Client::getPrivateId($this->client), 'client_id' => Client::getPrivateId($this->client),