Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="container" >
- <div class="row">
- <div class="col-md-12" style="margin-top: 50px; padding-left: 25em">
- <div class="col-md-3">
- <img src="{{$user->photo ? asset($user->photo->file) :
- asset('image/default.png')}}" style="width: 150px; height: 150px; float:
- left; border-radius: 50%; margin-right: 25px">
- </div>
- <div class="col-md-9 ">
- {!! Form::model($user, ['method'=>'PUT' ,'action'=>
- ['ProfileController@update',$user->id],'files'=>true])!!}
- <div class=form-group style="margin: 50px">
- <h2>{{$user->name}}'s profile</h2>
- {!! Form::label('name','Name :') !!}
- {!! Form::text('name', null , ['class'=>'form-control'])!!}
- {!! Form::label('email', 'Email :') !!}
- {!! Form::text('email', null, ['class'=>'form-control']) !!}
- {!! Form::label('photo_id', 'Profile Picture :') !!}
- {!! Form::file('photo_id', null, ['class'=>'form-control']) !!}
- {!! Form::label('password', 'Password:') !!}
- {!! Form::password('password', null, ['class'=>'form-control']) !!}
- </div>
- </div>
- <div class="row" style="padding-top: 20px; padding-left: 50%;">
- {!! Form::submit('Update Profile', ['class'=>'btn btn-info']) !!}
- {!! Form::close() !!}
- </div>
- </div>
- </div>
- </div>
- public function updateProfile(UserRequest $request, $id)
- {
- $user = User::findOrFail($id);
- if (trim($request->password)==''){
- $input = $request->except('password');
- }
- else{
- $input = $request->all();
- $input['password'] = bcrypt($request->password);
- }
- if ($request->file('photo_id'== '')){
- $input = $request->except('photo_id');
- }
- elseif ($file = $request->file('photo_id')){
- $name = time() . $file->getClientOriginalName();
- $file->move('image', $name);
- $photo = Photo::create(['file'=>$name]);
- $input['photo_id'] = $photo->id;
- }
- $user->update($input);
- // Session::flash('edited_profile','The profile has been updated');
- // $input['password'] = bcrypt($request->password);
- return redirect('/');
- // return $request->all();
- }
- Route::resource('/profile/', 'ProfileController');
- Route::get('/profile/{id}', 'ProfileController@editProfile')
- ->name('editProfile');
- Route::post('/profile/{id}', 'ProfileController@updateProfile')
- ->name('updateProfile');
Add Comment
Please, Sign In to add comment