1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Ninja/Datatables/ProjectDatatable.php

59 lines
1.6 KiB
PHP
Raw Normal View History

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