2016-12-23 17:52:00 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presenters;
|
|
|
|
|
|
|
|
use App\Helpers\Helper;
|
|
|
|
use App\Models\Setting;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class UserPresenter
|
|
|
|
* @package App\Presenters
|
|
|
|
*/
|
|
|
|
class UserPresenter extends Presenter
|
|
|
|
{
|
|
|
|
|
2017-02-03 22:20:11 -08:00
|
|
|
|
2016-12-23 17:52:00 -08:00
|
|
|
/**
|
2017-02-03 22:20:11 -08:00
|
|
|
* Json Column Layout for bootstrap table
|
|
|
|
* @return string
|
2016-12-23 17:52:00 -08:00
|
|
|
*/
|
2017-02-03 22:20:11 -08:00
|
|
|
public static function dataTableLayout()
|
2016-12-23 17:52:00 -08:00
|
|
|
{
|
2017-02-03 22:20:11 -08:00
|
|
|
$layout = [
|
|
|
|
[
|
|
|
|
"field" => "checkbox",
|
|
|
|
"checkbox" => true
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "id",
|
2017-03-03 17:53:42 -08:00
|
|
|
"searchable" => false,
|
2017-02-03 22:20:11 -08:00
|
|
|
"sortable" => true,
|
2017-03-03 17:53:42 -08:00
|
|
|
"switchable" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"title" => trans('general.id'),
|
2017-03-03 17:53:42 -08:00
|
|
|
"visible" => false
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2017-10-24 09:51:07 -07:00
|
|
|
[
|
|
|
|
"field" => "avatar",
|
|
|
|
"searchable" => false,
|
|
|
|
"sortable" => false,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => 'Avatar',
|
|
|
|
"visible" => false,
|
|
|
|
"formatter" => "imageFormatter"
|
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
|
|
|
"field" => "company",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/companies/table.title'),
|
|
|
|
"visible" => false,
|
|
|
|
"formatter" => "companiesLinkObjFormatter"
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "name",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"title" => trans('admin/users/table.name'),
|
|
|
|
"visible" => true,
|
|
|
|
"formatter" => "usersLinkFormatter"
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "jobtitle",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/table.title'),
|
|
|
|
"visible" => true,
|
|
|
|
"formatter" => "usersLinkFormatter"
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "email",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/table.email'),
|
|
|
|
"visible" => true,
|
|
|
|
"formatter" => "emailFormatter"
|
|
|
|
],
|
2017-10-23 14:21:51 -07:00
|
|
|
[
|
|
|
|
"field" => "phone",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/table.phone'),
|
|
|
|
"visible" => true,
|
2018-01-20 00:20:45 -08:00
|
|
|
"formatter" => "phoneFormatter",
|
2017-10-23 14:21:51 -07:00
|
|
|
],
|
2017-10-30 18:57:00 -07:00
|
|
|
[
|
|
|
|
"field" => "address",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.address'),
|
|
|
|
"visible" => false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "city",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.city'),
|
|
|
|
"visible" => false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "state",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.state'),
|
|
|
|
"visible" => false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "country",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.country'),
|
|
|
|
"visible" => false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "zip",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.zip'),
|
|
|
|
"visible" => false,
|
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
|
|
|
"field" => "username",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/table.username'),
|
|
|
|
"visible" => true,
|
|
|
|
"formatter" => "usersLinkFormatter"
|
|
|
|
],
|
2017-03-10 20:58:09 -08:00
|
|
|
[
|
|
|
|
"field" => "employee_num",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/table.employee_num'),
|
|
|
|
"visible" => false
|
|
|
|
],
|
2017-05-23 02:49:51 -07:00
|
|
|
[
|
|
|
|
"field" => "department",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.department'),
|
|
|
|
"visible" => true,
|
|
|
|
"formatter" => "departmentsLinkObjFormatter"
|
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
|
|
|
"field" => "location",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/table.location'),
|
2017-03-10 20:58:09 -08:00
|
|
|
"visible" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"formatter" => "locationsLinkObjFormatter"
|
|
|
|
],
|
2017-03-10 20:07:44 -08:00
|
|
|
[
|
|
|
|
"field" => "manager",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"title" => trans('admin/users/table.manager'),
|
|
|
|
"visible" => true,
|
|
|
|
"formatter" => "usersLinkObjFormatter"
|
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
|
|
|
"field" => "assets_count",
|
|
|
|
"searchable" => false,
|
2017-10-19 17:15:21 -07:00
|
|
|
"sortable" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"switchable" => true,
|
|
|
|
"title" => ' <span class="hidden-md hidden-lg">Assets</span>'
|
|
|
|
.'<span class="hidden-xs"><i class="fa fa-barcode fa-lg"></i></span>',
|
|
|
|
"visible" => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "licenses_count",
|
|
|
|
"searchable" => false,
|
2017-10-19 17:15:21 -07:00
|
|
|
"sortable" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"switchable" => true,
|
|
|
|
"title" => ' <span class="hidden-md hidden-lg">Licenses</span>'
|
|
|
|
.'<span class="hidden-xs"><i class="fa fa-floppy-o fa-lg"></i></span>',
|
|
|
|
"visible" => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "consumables_count",
|
|
|
|
"searchable" => false,
|
2017-10-19 17:15:21 -07:00
|
|
|
"sortable" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"switchable" => true,
|
|
|
|
"title" => ' <span class="hidden-md hidden-lg">Consumables</span>'
|
|
|
|
.'<span class="hidden-xs"><i class="fa fa-tint fa-lg"></i></span>',
|
|
|
|
"visible" => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "accessories_count",
|
|
|
|
"searchable" => false,
|
2017-10-19 17:15:21 -07:00
|
|
|
"sortable" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"switchable" => true,
|
|
|
|
"title" => ' <span class="hidden-md hidden-lg">Accessories</span>'
|
|
|
|
.'<span class="hidden-xs"><i class="fa fa-keyboard-o fa-lg"></i></span>',
|
|
|
|
"visible" => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "notes",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.notes'),
|
|
|
|
"visible" => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "groups",
|
|
|
|
"searchable" => false,
|
|
|
|
"sortable" => false,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.groups'),
|
|
|
|
"visible" => true,
|
|
|
|
'formatter' => 'groupsFormatter'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "two_factor_enrolled",
|
|
|
|
"searchable" => false,
|
2019-03-18 11:59:02 -07:00
|
|
|
"sortable" => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/general.two_factor_enrolled'),
|
|
|
|
"visible" => false,
|
|
|
|
'formatter' => 'trueFalseFormatter'
|
|
|
|
],
|
|
|
|
[
|
2019-03-18 11:59:02 -07:00
|
|
|
"field" => "two_factor_activated",
|
2017-02-03 22:20:11 -08:00
|
|
|
"searchable" => false,
|
|
|
|
"sortable" => false,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('admin/users/general.two_factor_active'),
|
|
|
|
"visible" => false,
|
|
|
|
'formatter' => 'trueFalseFormatter'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "activated",
|
|
|
|
"searchable" => false,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
2019-03-18 11:59:02 -07:00
|
|
|
"title" => trans('general.login_enabled'),
|
2017-02-03 22:20:11 -08:00
|
|
|
"visible" => true,
|
|
|
|
'formatter' => 'trueFalseFormatter'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "created_at",
|
|
|
|
"searchable" => true,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.created_at'),
|
|
|
|
"visible" => false,
|
2017-03-03 17:53:42 -08:00
|
|
|
'formatter' => 'dateDisplayFormatter'
|
2017-03-03 18:28:13 -08:00
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "last_login",
|
|
|
|
"searchable" => false,
|
|
|
|
"sortable" => true,
|
|
|
|
"switchable" => true,
|
|
|
|
"title" => trans('general.last_login'),
|
|
|
|
"visible" => false,
|
|
|
|
'formatter' => 'dateDisplayFormatter'
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
|
|
|
"field" => "actions",
|
|
|
|
"searchable" => false,
|
|
|
|
"sortable" => false,
|
|
|
|
"switchable" => false,
|
|
|
|
"title" => trans('table.actions'),
|
|
|
|
"visible" => true,
|
2017-02-08 18:20:23 -08:00
|
|
|
"formatter" => "usersActionsFormatter",
|
2017-02-03 22:20:11 -08:00
|
|
|
]
|
2016-12-23 17:52:00 -08:00
|
|
|
];
|
|
|
|
|
2017-02-03 22:20:11 -08:00
|
|
|
return json_encode($layout);
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|
2016-12-23 19:23:07 -08:00
|
|
|
|
2017-02-03 22:20:11 -08:00
|
|
|
|
2016-12-23 19:23:07 -08:00
|
|
|
public function emailLink()
|
|
|
|
{
|
|
|
|
if ($this->email) {
|
|
|
|
return '<a href="mailto:'.$this->email.'">'.$this->email.'</a>'
|
|
|
|
.'<a href="mailto:'.$this->email.'" class="hidden-xs hidden-sm"><i class="fa fa-envelope"></i></a>';
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
2016-12-23 17:52:00 -08:00
|
|
|
/**
|
|
|
|
* Returns the user full name, it simply concatenates
|
|
|
|
* the user first and last name.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function fullName()
|
|
|
|
{
|
|
|
|
return "{$this->first_name} {$this->last_name}";
|
|
|
|
}
|
|
|
|
|
2016-12-27 16:24:41 -08:00
|
|
|
/**
|
|
|
|
* Standard accessor.
|
|
|
|
* @TODO Remove presenter::fullName() entirely?
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function name()
|
|
|
|
{
|
|
|
|
return $this->fullName();
|
|
|
|
}
|
2016-12-23 17:52:00 -08:00
|
|
|
/**
|
|
|
|
* Returns the user Gravatar image url.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function gravatar()
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->avatar) {
|
|
|
|
return config('app.url').'/uploads/avatars/'.$this->avatar;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Setting::getSettings()->load_remote=='1') && ($this->email!='')) {
|
|
|
|
$gravatar = md5(strtolower(trim($this->email)));
|
|
|
|
return "//gravatar.com/avatar/".$gravatar;
|
|
|
|
}
|
|
|
|
|
2017-10-24 13:02:30 -07:00
|
|
|
// Set a fun, gender-neutral default icon
|
|
|
|
return url('/').'/img/default-sm.png';
|
2016-12-23 17:52:00 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Formatted url for use in tables.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function nameUrl()
|
|
|
|
{
|
|
|
|
return (string) link_to_route('users.show', $this->fullName(), $this->id);
|
|
|
|
}
|
2016-12-26 15:19:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Url to view this item.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function viewUrl()
|
|
|
|
{
|
|
|
|
return route('users.show', $this->id);
|
|
|
|
}
|
2016-12-29 18:12:27 -08:00
|
|
|
|
|
|
|
public function glyph()
|
|
|
|
{
|
2020-04-02 18:17:21 -07:00
|
|
|
return '<i class="fa fa-user" aria-hidden="true"></i>';
|
2016-12-29 18:12:27 -08:00
|
|
|
}
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|