I'm trying to take out STEAM_ID to nickname.
Example: I have table row called player_id, and another table users with row called username. I'm trying to convert STEAM_ID to username. Example: STEAM_0:0:1236546695 to username: ADMIN.
Code:
public function index()
{
$this->title('Banned players');
$this->indexPage([
'buttons' => null,
'brightenFirst' => false,
'sortby' => 'bid',
'tableHead' => [
'ID' => 'id',
'Player' => 'player_id',
'Length' => 'length',
'Reason' => 'reason',
'Banned by' => 'admin',
],
'tableRow' => function($bans_bans)
{
return [
$bans_bans->bid,
$bans->banusername,
$bans_bans->ban_length,
$bans_bans->ban_reason,
$bans_bans->admin_id,
];
$bans->banusername = User::where('steam_id', '=', $bans_bans->player_id)->first()->username;
},
'actions' => null,
], 'front');
}
But getting error:
Undefined variable: bans
Any help? I'm new on laravel so dont be mad on me! Thanks for answers guys!