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])) {
|
2016-07-07 10:44:15 +02:00
|
|
|
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) {
|
2016-07-07 10:44:15 +02:00
|
|
|
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
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|