Routes
Routes for profile and image upload:
Route::get('profile', 'UserController@profile');
//route to the users profile
Route::post('profile', 'UserController@update_avatar');
Route to the profile viewer that I want to create:
Route::get('/view', 'UserController@getView');
UserController
My profile logic. for avatar upload
public function profile()
{
return view('profile', array('user'=> Auth::user()) );
}
public function update_avatar(Request $request)
{
if($request->hasFile('avatar')) {
$avatar = $request->file('avatar');
$filename = time().'.'. $avatar->getClientOriginalExtension();
Image::make($avatar)->resize(300, 300)
->save(public_path("/uploads/avatars/$filename"));
$user = Auth::user();
$user->avatar = $filename;
$user->save();
}
return view('profile', array('user'=> Auth::user()));
}
// getView function, I have no idea what to put here
public function getView()
{
return view('view', array('user'=> Auth::user()));
}
My profile view in views.blade.php
:
I need this to be shown when a user needs to view another profile
<section>
<div class="mbr-box mbr-section mbr-section--relative mbr-section--fixed-size mbr-section--full-height mbr-section--bg-adapted mbr-parallax-backgroundr">
<div class="jumbotron" style="width:800px; height:700px; border-radius:10px; float:left; padding-top:15px; margin-left:20px;">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="col-md-10 col-md-offset-1">
<img src="/uploads/avatars/{{$user->avatar}}" style= "padding-top:15px; width:150px; float:left; height:150px; border-radius:50%; margin-right:25px;">
<h2>{{$user-> name }}'s Profile from {{$user->city}}</h2>
<form enctype="multipart/form-data" action="/profile" method="POST" id="hover">
<label>update profile image</label>
<input type="file" name="avatar">
<input type="hidden" name ="_token" value="{{ csrf_token() }}">
<input type="submit" class="pull-right btn-sm btn-default" value="Send Picture">
</form><br/>
<h1 style="font:sans serif, Helvitica; color:#d1d5d5;"> Taking {{$user->course}} </h1>
</div>
</div>
</div>
</div>
</div>
</div>
</section>