invoiceninja/app/Ninja/Datatables/ProposalSnippetDatatable.php

61 lines
1.7 KiB
PHP
Raw Normal View History

2018-01-30 20:58:55 +02:00
<?php
namespace App\Ninja\Datatables;
use Auth;
use URL;
use Utils;
class ProposalSnippetDatatable extends EntityDatatable
{
public $entityType = ENTITY_PROPOSAL_SNIPPET;
public $sortCol = 1;
public function columns()
{
return [
[
2018-02-04 18:47:55 +02:00
'name',
2018-01-30 20:58:55 +02:00
function ($model) {
if (! Auth::user()->can('editByOwner', [ENTITY_PROPOSAL_SNIPPET, $model->user_id])) {
2018-02-04 18:47:55 +02:00
return $model->name;
2018-01-30 20:58:55 +02:00
}
2018-02-04 18:47:55 +02:00
return link_to("proposals/snippets/{$model->public_id}/edit", $model->name)->toHtml();
2018-02-04 17:31:45 +02:00
},
],
[
'category',
function ($model) {
if (! Auth::user()->can('editByOwner', [ENTITY_PROPOSAL_CATEGORY, $model->category_user_id])) {
return $model->category;
}
return link_to("proposals/categories/{$model->category_public_id}/edit", $model->category)->toHtml();
2018-01-30 20:58:55 +02:00
},
],
2018-02-04 18:42:13 +02:00
[
'private_notes',
function ($model) {
return $this->showWithTooltip($model->private_notes);
},
],
2018-01-30 20:58:55 +02:00
];
}
public function actions()
{
return [
[
2018-02-04 17:31:45 +02:00
trans('texts.edit_proposal_snippet'),
2018-01-30 20:58:55 +02:00
function ($model) {
2018-02-04 17:31:45 +02:00
return URL::to("proposals/snippets/{$model->public_id}/edit");
2018-01-30 20:58:55 +02:00
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_PROPOSAL_SNIPPET, $model->user_id]);
},
],
];
}
}