mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-10-18 17:10:56 -04:00
* migration for new permissions schema * update permissions across data tables * refactor migrations to prevent duplicate attribute * update permissions in views * Product Permissions * permissions via controllers * Refactor to use Laravel authorization gate * Doc Blocks for EntityPolicy * check permissions conditional on create new client * Bug Fixes * Data table permissions * working on UI * settings UI/UX finalised * Datatable permissions * remove legacy permissions * permission fix for viewing client * remove all instances of viewByOwner * refactor after PR * Bug fix for Functional test and implementation of Functional tests for Permissions * fix for tests
84 lines
2.2 KiB
PHP
84 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Ninja\Datatables;
|
|
|
|
use Auth;
|
|
use URL;
|
|
use Utils;
|
|
|
|
class VendorDatatable extends EntityDatatable
|
|
{
|
|
public $entityType = ENTITY_VENDOR;
|
|
public $sortCol = 4;
|
|
|
|
public function columns()
|
|
{
|
|
return [
|
|
[
|
|
'name',
|
|
function ($model) {
|
|
$str = link_to("vendors/{$model->public_id}", $model->name ?: '')->toHtml();
|
|
return $this->addNote($str, $model->private_notes);
|
|
},
|
|
],
|
|
[
|
|
'city',
|
|
function ($model) {
|
|
return $model->city;
|
|
},
|
|
],
|
|
[
|
|
'work_phone',
|
|
function ($model) {
|
|
return $model->work_phone;
|
|
},
|
|
],
|
|
[
|
|
'email',
|
|
function ($model) {
|
|
return link_to("vendors/{$model->public_id}", $model->email ?: '')->toHtml();
|
|
},
|
|
],
|
|
[
|
|
'created_at',
|
|
function ($model) {
|
|
return Utils::timestampToDateString(strtotime($model->created_at));
|
|
},
|
|
],
|
|
];
|
|
}
|
|
|
|
public function actions()
|
|
{
|
|
return [
|
|
[
|
|
trans('texts.edit_vendor'),
|
|
function ($model) {
|
|
return URL::to("vendors/{$model->public_id}/edit");
|
|
},
|
|
function ($model) {
|
|
return Auth::user()->can('view', [ENTITY_VENDOR, $model]);
|
|
},
|
|
],
|
|
[
|
|
'--divider--', function () {
|
|
return false;
|
|
},
|
|
function ($model) {
|
|
return Auth::user()->can('edit', [ENTITY_VENDOR, $model]) && Auth::user()->can('create', ENTITY_EXPENSE);
|
|
},
|
|
|
|
],
|
|
[
|
|
trans('texts.enter_expense'),
|
|
function ($model) {
|
|
return URL::to("expenses/create/0/{$model->public_id}");
|
|
},
|
|
function ($model) {
|
|
return Auth::user()->can('create', ENTITY_EXPENSE);
|
|
},
|
|
],
|
|
];
|
|
}
|
|
}
|