invoiceninja/app/Ninja/Datatables/ProjectDatatable.php

59 lines
1.6 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Datatables;
2016-11-29 19:47:26 +02:00
use Auth;
2017-01-30 21:40:43 +02:00
use URL;
use Utils;
2016-11-29 19:47:26 +02:00
class ProjectDatatable extends EntityDatatable
{
public $entityType = ENTITY_PROJECT;
public $sortCol = 1;
public function columns()
{
return [
[
'project',
2017-01-30 18:05:31 +02:00
function ($model) {
if (! Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id])) {
2016-11-29 19:47:26 +02:00
return $model->project;
}
return link_to("projects/{$model->public_id}/edit", $model->project)->toHtml();
2017-01-30 21:40:43 +02:00
},
2016-11-29 19:47:26 +02:00
],
[
'client_name',
2017-01-30 18:05:31 +02:00
function ($model) {
2016-11-29 19:47:26 +02:00
if ($model->client_public_id) {
2017-01-30 21:40:43 +02:00
if (! Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) {
2016-11-29 19:47:26 +02:00
return Utils::getClientDisplayName($model);
}
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
} else {
return '';
}
2017-01-30 21:40:43 +02:00
},
],
2016-11-29 19:47:26 +02:00
];
}
public function actions()
{
return [
[
trans('texts.edit_project'),
function ($model) {
2017-01-30 21:40:43 +02:00
return URL::to("projects/{$model->public_id}/edit");
2016-11-29 19:47:26 +02:00
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id]);
2017-01-30 21:40:43 +02:00
},
2016-11-29 19:47:26 +02:00
],
];
}
}