![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/corals-api/Corals/core/User/Transformers/ |
<?php namespace Corals\User\Transformers; use Corals\Foundation\Transformers\BaseTransformer; use Corals\Modules\Utility\Facades\ListOfValue\ListOfValues; use Corals\User\Models\User; class UserTransformer extends BaseTransformer { public function __construct($extras = []) { $this->resource_url = config('user.models.user.resource_url'); parent::__construct($extras); } /** * @param User $user * @return array * @throws \Throwable */ public function transform(User $user) { $show_url = $user->getShowURL(); $canViewUser = user() && user()->can('view', $user); $img = '<img src="' . $user->picture_thumb . '" class="img-circle img-responsive" alt="User Picture" width="35"/>'; $positions = ListOfValues::get('positions'); $employee_type = ListOfValues::get('employee_type'); $transformedArray = [ 'id' => $user->id, 'full_name' => $canViewUser ? ('<a href="' . $show_url . '">' . $user->full_name . '</a>') : $user->full_name, 'checkbox' => $this->generateCheckboxElement($user), 'name' => $canViewUser ? ('<a href="' . $show_url . '">' . $user->name . '</a>') : $user->name, 'last_name' => $user->last_name, 'email' => $user->email, 'status' => formatStatusAsLabels($user->status), 'confirmed' => $user->confirmed ? '✔' : '-', 'roles' => formatArrayAsLabels($user->roles->pluck('label'), 'success'), 'picture' => $user->picture, 'picture_thumb' => $canViewUser ? ('<a href="' . $show_url . '">' . $img . '</a>') : $img, 'position' => $user->position ? data_get($positions, $user->position, $user->position) : '-', 'employee_type' => $user->employee_type ? data_get($employee_type, $user->employee_type, $user->employee_type) : '-', 'created_at' => format_date($user->created_at), 'updated_at' => format_date($user->updated_at), 'action' => $this->actions($user), ]; return parent::transformResponse($transformedArray, $user); } }