I want to return a profile with full name and username, but when I try to pass the data, those fields disappear when the view loads up.
In my Profiles Controller I tried the following:
public function show(User $user)
{
return view('profile')->with(['user' => $user]);
}
I also tried:
public function show(User $user)
{
return view('profile', compact('user));
}
And also tried:
public function show(User $user)
{
return view('profile', ['user' => $user]);
}
And yes, I already have use App\Http\Controllers\ProfilesController; as I made controller with this command php artisan make:controller ProfilesController --resource --model=Photo
My resource route in web.php is:
Route::resource('/profile', ProfilesController::class)->names([
'show' => 'profile.show'
])
The view is loading up fine, just without the data to passed in.
<div class="profile_full_name_div">
<p class="profile_full_name">{{ $user->name }}</p>
</div>
<div class="profile_username_div">
<p class="profile_username">{{ $user->username }}</p>
</div>
Whenever I put in a hardcore name, the username and full name info would reappear into the view. For example:
<div class="profile_full_name_div">
<p class="profile_full_name">Susan Bowe</p>
</div>
<div class="profile_username_div">
<p class="profile_username">susan_bowe</p>
</div>