ProfileController.php
Go to the documentation of this file.
1 <?php
2 namespace App\Http\Controllers;
3 
4 use Image;
5 use Input;
6 use Redirect;
8 use View;
9 use Auth;
11 
19 {
27  public function getIndex()
28  {
29  // Get the user information
30  $user = Auth::user();
31  $location_list = Helper::locationsList();
32  return View::make('account/profile', compact('user'))->with('location_list', $location_list);
33  }
34 
42  public function postIndex()
43  {
44 
45  // Grab the user
46  $user = Auth::user();
47 
48  // Update the user information
49  $user->first_name = e(Input::get('first_name'));
50  $user->last_name = e(Input::get('last_name'));
51  $user->website = e(Input::get('website'));
52  $user->location_id = e(Input::get('location_id'));
53  $user->gravatar = e(Input::get('gravatar'));
54  $user->locale = e(Input::get('locale'));
55 
56  if (Input::file('avatar')) {
57  $image = Input::file('avatar');
58  $file_name = $user->first_name."-".$user->last_name.".".$image->getClientOriginalExtension();
59  $path = public_path('uploads/avatars/'.$file_name);
60  Image::make($image->getRealPath())->resize(84, 84)->save($path);
61  $user->avatar = $file_name;
62  }
63 
64  if (Input::get('avatar_delete') == 1 && Input::file('avatar') == "") {
65  $user->avatar = null;
66  }
67 
68  if ($user->save()) {
69  return Redirect::route('profile')->with('success', 'Account successfully updated');
70  }
71  return Redirect::back()->withInput()->withErrors($user->getErrors());
72  }
73 }
postIndex()
Validates and stores the user&#39;s update data.
static locationsList()
Definition: Helper.php:94
getIndex()
Returns a view with the user&#39;s profile form for editing.
This controller handles all actions related to User Profiles for the Snipe-IT Asset Management applic...