2016-12-23 17:52:00 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presenters;
|
|
|
|
|
2020-04-24 05:55:38 -07:00
|
|
|
use App\Helpers\Helper;
|
|
|
|
use App\Models\Setting;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
2020-08-26 12:17:18 -07:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2016-12-23 17:52:00 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class UserPresenter
|
|
|
|
*/
|
|
|
|
class UserPresenter extends Presenter
|
|
|
|
{
|
|
|
|
/**
|
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 = [
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'checkbox',
|
|
|
|
'checkbox' => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'id',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.id'),
|
|
|
|
'visible' => false,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2017-10-24 09:51:07 -07:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'avatar',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => 'Avatar',
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'imageFormatter',
|
2017-10-24 09:51:07 -07:00
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'company',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/companies/table.title'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'companiesLinkObjFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'name',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/users/table.name'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'usersLinkFormatter',
|
2021-06-28 15:55:33 -07:00
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
'field' => 'first_name',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('general.first_name'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'usersLinkFormatter',
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
'field' => 'last_name',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('general.last_name'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'usersLinkFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'jobtitle',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/table.title'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'usersLinkFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2022-03-04 05:35:26 -08:00
|
|
|
[
|
|
|
|
'field' => 'remote',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/general.remote'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'trueFalseFormatter',
|
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'email',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/table.email'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'emailFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2017-10-23 14:21:51 -07:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'phone',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/table.phone'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'phoneFormatter',
|
2017-10-23 14:21:51 -07:00
|
|
|
],
|
2017-10-30 18:57:00 -07:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'address',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.address'),
|
|
|
|
'visible' => false,
|
2017-10-30 18:57:00 -07:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'city',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.city'),
|
|
|
|
'visible' => false,
|
2017-10-30 18:57:00 -07:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'state',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.state'),
|
|
|
|
'visible' => false,
|
2017-10-30 18:57:00 -07:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'country',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.country'),
|
|
|
|
'visible' => false,
|
2017-10-30 18:57:00 -07:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'zip',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.zip'),
|
|
|
|
'visible' => false,
|
2017-10-30 18:57:00 -07:00
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'username',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/table.username'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'usersLinkFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2017-03-10 20:58:09 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'employee_num',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
2022-01-06 03:35:37 -08:00
|
|
|
'title' => trans('general.employee_number'),
|
2021-06-10 13:15:52 -07:00
|
|
|
'visible' => false,
|
2017-03-10 20:58:09 -08:00
|
|
|
],
|
2017-05-23 02:49:51 -07:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'department',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.department'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'departmentsLinkObjFormatter',
|
2017-05-23 02:49:51 -07:00
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'location',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/table.location'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'locationsLinkObjFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2017-03-10 20:07:44 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'manager',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/users/table.manager'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'usersLinkObjFormatter',
|
2017-03-10 20:07:44 -08:00
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
2020-04-24 05:55:38 -07:00
|
|
|
'field' => 'assets_count',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'escape' => true,
|
|
|
|
'class' => 'css-barcode',
|
|
|
|
'title' => 'Assets',
|
|
|
|
'visible' => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'licenses_count',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
2020-04-24 05:55:38 -07:00
|
|
|
'class' => 'css-license',
|
2021-06-10 13:15:52 -07:00
|
|
|
'title' => 'License',
|
|
|
|
'visible' => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'consumables_count',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
2020-04-24 05:55:38 -07:00
|
|
|
'class' => 'css-consumable',
|
2021-06-10 13:15:52 -07:00
|
|
|
'title' => 'Consumables',
|
|
|
|
'visible' => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'accessories_count',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
2020-04-24 05:55:38 -07:00
|
|
|
'class' => 'css-accessory',
|
2021-06-10 13:15:52 -07:00
|
|
|
'title' => 'Accessories',
|
|
|
|
'visible' => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'notes',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.notes'),
|
|
|
|
'visible' => true,
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'groups',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.groups'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'groupsFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'ldap_import',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/settings/general.ldap_enabled'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'trueFalseFormatter',
|
2020-12-02 11:01:05 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'two_factor_enrolled',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/general.two_factor_enrolled'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'trueFalseFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'two_factor_activated',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/users/general.two_factor_active'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'trueFalseFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'activated',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.login_enabled'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'trueFalseFormatter',
|
2017-02-03 22:20:11 -08:00
|
|
|
],
|
2022-06-23 17:18:04 -07:00
|
|
|
[
|
|
|
|
'field' => 'created_by',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
2022-06-23 19:11:59 -07:00
|
|
|
'title' => trans('general.created_by'),
|
2022-06-23 17:28:34 -07:00
|
|
|
'visible' => false,
|
2022-06-23 17:18:04 -07:00
|
|
|
'formatter' => 'usersLinkObjFormatter',
|
|
|
|
],
|
2017-02-03 22:20:11 -08:00
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'created_at',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.created_at'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2017-03-03 18:28:13 -08:00
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07: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
|
|
|
],
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'actions',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'switchable' => false,
|
|
|
|
'title' => trans('table.actions'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'usersActionsFormatter',
|
|
|
|
],
|
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
|
|
|
|
|
|
|
public function emailLink()
|
|
|
|
{
|
|
|
|
if ($this->email) {
|
|
|
|
return '<a href="mailto:'.$this->email.'">'.$this->email.'</a>'
|
2021-09-24 13:07:02 -07:00
|
|
|
.'<a href="mailto:'.$this->email.'" class="hidden-xs hidden-sm"><i class="far fa-envelope"></i></a>';
|
2016-12-23 19:23:07 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-12-23 19:23:07 -08:00
|
|
|
return '';
|
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
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()
|
|
|
|
{
|
2020-11-25 08:54:23 -08:00
|
|
|
return html_entity_decode($this->first_name.' '.$this->last_name, ENT_QUOTES | ENT_XML1, 'UTF-8');
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|
|
|
|
|
2016-12-27 16:24:41 -08:00
|
|
|
/**
|
|
|
|
* Standard accessor.
|
|
|
|
* @TODO Remove presenter::fullName() entirely?
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function name()
|
|
|
|
{
|
|
|
|
return $this->fullName();
|
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-12-23 17:52:00 -08:00
|
|
|
/**
|
|
|
|
* Returns the user Gravatar image url.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function gravatar()
|
|
|
|
{
|
|
|
|
if ($this->avatar) {
|
2020-08-26 12:17:18 -07:00
|
|
|
return Storage::disk('public')->url('avatars/'.e($this->avatar));
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
if (Setting::getSettings()->load_remote == '1') {
|
|
|
|
if ($this->model->gravatar != '') {
|
2020-05-13 11:30:47 -07:00
|
|
|
$gravatar = md5(strtolower(trim($this->model->gravatar)));
|
2021-06-10 13:15:52 -07:00
|
|
|
|
|
|
|
return '//gravatar.com/avatar/'.$gravatar;
|
|
|
|
} elseif ($this->email != '') {
|
2020-05-13 11:30:47 -07:00
|
|
|
$gravatar = md5(strtolower(trim($this->email)));
|
2021-06-10 13:15:52 -07:00
|
|
|
|
|
|
|
return '//gravatar.com/avatar/'.$gravatar;
|
2020-05-13 11:30:47 -07:00
|
|
|
}
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|
|
|
|
|
2020-04-24 05:55:38 -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()
|
|
|
|
{
|
2021-09-26 01:11:08 -07:00
|
|
|
return '<i class="fas fa-user" aria-hidden="true"></i>';
|
2016-12-29 18:12:27 -08:00
|
|
|
}
|
2020-05-13 11:30:47 -07:00
|
|
|
}
|