Guest User

Untitled

a guest
Feb 8th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <div class="container" >
  2. <div class="row">
  3. <div class="col-md-12" style="margin-top: 50px; padding-left: 25em">
  4. <div class="col-md-3">
  5. <img src="{{$user->photo ? asset($user->photo->file) :
  6. asset('image/default.png')}}" style="width: 150px; height: 150px; float:
  7. left; border-radius: 50%; margin-right: 25px">
  8. </div>
  9. <div class="col-md-9 ">
  10. {!! Form::model($user, ['method'=>'PUT' ,'action'=>
  11. ['ProfileController@update',$user->id],'files'=>true])!!}
  12. <div class=form-group style="margin: 50px">
  13. <h2>{{$user->name}}'s profile</h2>
  14. {!! Form::label('name','Name :') !!}
  15. {!! Form::text('name', null , ['class'=>'form-control'])!!}
  16. {!! Form::label('email', 'Email :') !!}
  17. {!! Form::text('email', null, ['class'=>'form-control']) !!}
  18. {!! Form::label('photo_id', 'Profile Picture :') !!}
  19. {!! Form::file('photo_id', null, ['class'=>'form-control']) !!}
  20. {!! Form::label('password', 'Password:') !!}
  21. {!! Form::password('password', null, ['class'=>'form-control']) !!}
  22.  
  23. </div>
  24. </div>
  25. <div class="row" style="padding-top: 20px; padding-left: 50%;">
  26. {!! Form::submit('Update Profile', ['class'=>'btn btn-info']) !!}
  27. {!! Form::close() !!}
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32.  
  33. public function updateProfile(UserRequest $request, $id)
  34. {
  35. $user = User::findOrFail($id);
  36. if (trim($request->password)==''){
  37. $input = $request->except('password');
  38. }
  39. else{
  40. $input = $request->all();
  41. $input['password'] = bcrypt($request->password);
  42. }
  43. if ($request->file('photo_id'== '')){
  44. $input = $request->except('photo_id');
  45. }
  46. elseif ($file = $request->file('photo_id')){
  47. $name = time() . $file->getClientOriginalName();
  48. $file->move('image', $name);
  49. $photo = Photo::create(['file'=>$name]);
  50. $input['photo_id'] = $photo->id;
  51. }
  52. $user->update($input);
  53. // Session::flash('edited_profile','The profile has been updated');
  54. // $input['password'] = bcrypt($request->password);
  55. return redirect('/');
  56. // return $request->all();
  57. }
  58.  
  59. Route::resource('/profile/', 'ProfileController');
  60. Route::get('/profile/{id}', 'ProfileController@editProfile')
  61. ->name('editProfile');
  62. Route::post('/profile/{id}', 'ProfileController@updateProfile')
  63. ->name('updateProfile');
Add Comment
Please, Sign In to add comment