1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Ninja/Datatables/ExpenseCategoryDatatable.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Datatables;
2016-07-06 20:35:16 +02:00
use Auth;
2017-01-30 20:40:43 +01:00
use URL;
2016-07-06 20:35:16 +02:00
class ExpenseCategoryDatatable extends EntityDatatable
{
public $entityType = ENTITY_EXPENSE_CATEGORY;
2016-11-24 10:41:11 +01:00
public $sortCol = 1;
2016-07-06 20:35:16 +02:00
public function columns()
{
return [
[
'name',
2017-01-30 17:05:31 +01:00
function ($model) {
if (! Auth::user()->can('editByOwner', [ENTITY_EXPENSE_CATEGORY, $model->user_id])) {
return $model->category;
}
return link_to("expense_categories/{$model->public_id}/edit", $model->category)->toHtml();
2017-01-30 20:40:43 +01:00
},
2016-07-06 20:35:16 +02:00
],
];
}
public function actions()
{
return [
[
trans('texts.edit_category'),
function ($model) {
2017-01-30 20:40:43 +01:00
return URL::to("expense_categories/{$model->public_id}/edit");
2016-07-06 20:35:16 +02:00
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_EXPENSE_CATEGORY, $model->user_id]);
2017-01-30 20:40:43 +01:00
},
2016-07-06 20:35:16 +02:00
],
];
}
}