Laravel在视图中访问阵列数据

I know I am very close, I'm just stuck and can't figure out this last step.

I'm trying to echo out some information in my blade template, but I'm getting the following error: Undefined property: Illuminate\Database\Eloquent\Collection::$Moniker

Here is my controller, which returns the $data variable to the view:

$user = User::where('id', $request)->get();
$data = array(
    'images'  => $images,
    'user'   => $user
);
return view('a_profile')->with('data', $data);  

Here is my view:

<title>{{$data['user']->Moniker}} | My Company | Baltimore, MD</title>

How do I get the Moniker which is a column in my users table to echo out, in this case? Thank you! :)

using get() method will return you records in array into array format like this,

your query,

$user = User::where('id', $request)->get();

result would be this

array(
   array(
     'id'  =>1,
     'name'=>'xyz' 
   )
)

So, in your view, instead of looping, you can access the column doing this,

<title>{{$data['user'][0]->Moniker}} | My Company | Baltimore, MD</title>

So convert your query into this first(), because you want to return single record,

$user = User::where('id', $request)->first();

this will return the result into single array format

array(
  'id'  =>1,
  'name'=>'xyz' 
)

and you can access into your view, simple doing this

<title>{{$data['user']->Moniker}} | My Company | Baltimore, MD</title>