2016-07-21 14:35:23 +02:00
|
|
|
<?php namespace App\Ninja\Datatables;
|
2016-07-06 20:35:16 +02:00
|
|
|
|
2016-07-21 14:35:23 +02:00
|
|
|
use Utils;
|
2016-07-06 20:35:16 +02:00
|
|
|
use URL;
|
|
|
|
use Auth;
|
|
|
|
|
|
|
|
class ExpenseCategoryDatatable extends EntityDatatable
|
|
|
|
{
|
|
|
|
public $entityType = ENTITY_EXPENSE_CATEGORY;
|
|
|
|
|
|
|
|
public function columns()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'name',
|
|
|
|
function ($model)
|
|
|
|
{
|
2016-07-07 10:44:15 +02:00
|
|
|
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();
|
2016-07-06 20:35:16 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function actions()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
trans('texts.edit_category'),
|
|
|
|
function ($model) {
|
|
|
|
return URL::to("expense_categories/{$model->public_id}/edit") ;
|
|
|
|
},
|
|
|
|
function ($model) {
|
2016-07-07 10:44:15 +02:00
|
|
|
return Auth::user()->can('editByOwner', [ENTITY_EXPENSE_CATEGORY, $model->user_id]);
|
2016-07-06 20:35:16 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|