I'm trying to take an output from a db, search pass it over from a controller using compact, and then pass it to a custom blade helper.
When I pass over the db details I get a value of said users id and this can be displayed using
@foreach($SelectUser as $key => $UserArray)
{{$UserArray->user_id}}
@endforeach
I will get an output as expected of a users id e.g. 1.
When I try to combine this with my helper to change the value in to a readable username it dose not seam to output a value for the helper class to convert to a readable username.
@foreach($selectUseras $key => $UserArray)
@FindUsername($UserArray->user_id)
@endforeach
helper class is
public function boot()
{
//A Helper to translate a user id number in to a readable username
Blade::directive('FindUsername', function ($id) {
// Request infomation from the db useing eloquent
$username = User::where('id', $id)
->pluck('username');
//Results to an array
$arr = $username->toArray();
//Filter through array results
$i = implode(" ",$arr);
return $i;
});
}