Asked by: Anna Jeanine
I am working on a profile page for my web application. Within this view profile.blade.php
I would like to include the view progress/index.blade.php
. I have the following structure:
profile.blade.php
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h1 class="panel-title pull-left">{{ $user->name }} Progress</h1>
</div>
<div class="panel-body">
@include('client.progress.index')
</div>
</div>
web.php
Route::group(['middleware' => ['auth', 'client'], 'prefix' => 'client', 'as' => 'client.'], function () {
Route::get('home', 'Client\HomeController@index')->name('home');
Route::get('profile', 'Client\UserController@profile')->name('profile');
Route::get('progress', 'Client\UserController@progress')->name('progress.index');
});
UserController@progress
public function progress(){
$auth = Auth::user();
$progressPictures = Picture::select('*')
->where('user_id', $auth->id)
->get();
return view('client.progress.index', ['progressPictures' => $progressPictures]);
}
client.progress.index
<p>Progress pictures</p>
@foreach($progressPictures as $progressPicture)
<img src="/storage/uploads/progress/{{ $progressPicture }}" style="width:150px; height:150px; float:left; border-radius:50%; margin-right:25px;">
@endforeach
When I remove the php part from the index.blade.php
, the site works. but when i add the foreach
loop, $progressPictures
is undefined. I am not calling the UserController@progress
in some way. Could some one help me with this?
No comments:
Post a Comment