mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 19:59:18 -08:00
Replace the assorted concat() methods with a full_name method in the User model and adjust queries accordingly
This commit is contained in:
parent
0e0b31bba6
commit
4b98711e07
|
@ -164,11 +164,11 @@ class Helper
|
|||
|
||||
public static function managerList()
|
||||
{
|
||||
$manager_list = array('' => '') + User::select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
|
||||
->whereNull('deleted_at', 'and')
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')
|
||||
->pluck('full_name', 'id')->toArray();
|
||||
$manager_list = User::where('deleted_at', '=', null)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')->get()
|
||||
->lists('full_name', 'id');
|
||||
|
||||
return $manager_list;
|
||||
}
|
||||
|
||||
|
@ -187,13 +187,12 @@ class Helper
|
|||
|
||||
public static function usersList()
|
||||
{
|
||||
$users_list = array('' => trans('general.select_user')) + DB::table('users')
|
||||
->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
|
||||
->whereNull('deleted_at')
|
||||
->where('show_in_list','=',1)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')
|
||||
->pluck('full_name', 'id');
|
||||
$users_list = User::where('deleted_at', '=', null)
|
||||
->where('show_in_list','=',1)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')->get()
|
||||
->lists('full_name', 'id');
|
||||
|
||||
return $users_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -435,8 +435,7 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
$users_list = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))->whereNull('deleted_at')->orderBy('last_name', 'asc')->orderBy('first_name', 'asc')->lists('full_name', 'id');
|
||||
|
||||
$users_list = Helper::usersList();
|
||||
|
||||
// Left join to get a list of assets and some other helpful info
|
||||
$asset = DB::table('assets')
|
||||
|
|
|
@ -118,6 +118,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
return "{$this->first_name} {$this->last_name}";
|
||||
}
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->first_name . " " . $this->last_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user Gravatar image url.
|
||||
|
|
Loading…
Reference in a new issue