invoiceninja/app/Ninja/Datatables/ExpenseCategoryDatatable.php

44 lines
1.1 KiB
PHP
Raw Permalink Normal View History

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