mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 23:22:52 +01:00
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
|
<?php namespace App\Ninja\Datatables;
|
||
|
|
||
|
use Utils;
|
||
|
use URL;
|
||
|
use Auth;
|
||
|
|
||
|
class ProjectDatatable extends EntityDatatable
|
||
|
{
|
||
|
public $entityType = ENTITY_PROJECT;
|
||
|
public $sortCol = 1;
|
||
|
|
||
|
public function columns()
|
||
|
{
|
||
|
return [
|
||
|
[
|
||
|
'project',
|
||
|
function ($model)
|
||
|
{
|
||
|
if ( ! Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id])) {
|
||
|
return $model->project;
|
||
|
}
|
||
|
|
||
|
return link_to("projects/{$model->public_id}/edit", $model->project)->toHtml();
|
||
|
}
|
||
|
],
|
||
|
[
|
||
|
'client_name',
|
||
|
function ($model)
|
||
|
{
|
||
|
if ($model->client_public_id) {
|
||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
||
|
return Utils::getClientDisplayName($model);
|
||
|
}
|
||
|
|
||
|
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
||
|
} else {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function actions()
|
||
|
{
|
||
|
return [
|
||
|
[
|
||
|
trans('texts.edit_project'),
|
||
|
function ($model) {
|
||
|
return URL::to("projects/{$model->public_id}/edit") ;
|
||
|
},
|
||
|
function ($model) {
|
||
|
return Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id]);
|
||
|
}
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
}
|