Changed method and scope names

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-06-23 18:41:13 -07:00
parent 9c9f5be6fe
commit 3e559044b2
4 changed files with 10 additions and 10 deletions

View file

@ -188,7 +188,7 @@ class UsersController extends Controller
$users = $users->OrderDepartment($order); $users = $users->OrderDepartment($order);
break; break;
case 'created_by': case 'created_by':
$users = $users->OrderAdmin($order); $users = $users->CreatedBy($order);
break; break;
case 'company': case 'company':
$users = $users->OrderCompany($order); $users = $users->OrderCompany($order);

View file

@ -63,9 +63,9 @@ class UsersTransformer
'accessories_count' => (int) $user->accessories_count, 'accessories_count' => (int) $user->accessories_count,
'consumables_count' => (int) $user->consumables_count, 'consumables_count' => (int) $user->consumables_count,
'company' => ($user->company) ? ['id' => (int) $user->company->id, 'name'=> e($user->company->name)] : null, 'company' => ($user->company) ? ['id' => (int) $user->company->id, 'name'=> e($user->company->name)] : null,
'created_by' => ($user->adminuser) ? [ 'created_by' => ($user->createdBy) ? [
'id' => (int) $user->adminuser->id, 'id' => (int) $user->createdBy->id,
'name'=> e($user->adminuser->present()->fullName), 'name'=> e($user->createdBy->present()->fullName),
] : null, ] : null,
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),

View file

@ -568,7 +568,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation * @return \Illuminate\Database\Eloquent\Relations\Relation
*/ */
public function adminuser() public function createdBy()
{ {
return $this->belongsTo(\App\Models\User::class, 'created_by')->withTrashed(); return $this->belongsTo(\App\Models\User::class, 'created_by')->withTrashed();
} }
@ -705,7 +705,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* *
* @return \Illuminate\Database\Query\Builder Modified query builder * @return \Illuminate\Database\Query\Builder Modified query builder
*/ */
public function scopeOrderAdmin($query, $order) public function scopeCreatedBy($query, $order)
{ {
// Left join here, or it will only return results with parents // Left join here, or it will only return results with parents
return $query->leftJoin('users as admin_user', 'users.created_by', '=', 'admin_user.id') return $query->leftJoin('users as admin_user', 'users.created_by', '=', 'admin_user.id')

View file

@ -464,12 +464,12 @@
<div class="col-md-9"> <div class="col-md-9">
{{ \App\Helpers\Helper::getFormattedDateObject($user->created_at, 'datetime')['formatted']}} {{ \App\Helpers\Helper::getFormattedDateObject($user->created_at, 'datetime')['formatted']}}
@if ($user->adminuser) @if ($user->createdBy)
by by
@if ($user->adminuser->deleted_at=='') @if ($user->createdBy->deleted_at=='')
<a href="{{ route('users.show', ['user' => $user->user_id]) }}">{{ $user->adminuser->present()->fullName }}</a> <a href="{{ route('users.show', ['user' => $user->user_id]) }}">{{ $user->createdBy->present()->fullName }}</a>
@else @else
<del>{{ $user->adminuser->present()->fullName }}</del> <del>{{ $user->createdBy->present()->fullName }}</del>
@endif @endif