App\Http\Controllers\ProfileController Class Reference

This controller handles all actions related to User Profiles for the Snipe-IT Asset Management application. More...

Inheritance diagram for App\Http\Controllers\ProfileController:
App\Http\Controllers\Controller

Public Member Functions

 getIndex ()
 Returns a view with the user's profile form for editing. More...
 
 postIndex ()
 Validates and stores the user's update data. More...
 

Detailed Description

This controller handles all actions related to User Profiles for the Snipe-IT Asset Management application.

Version
v1.0

Definition at line 18 of file ProfileController.php.

Member Function Documentation

App\Http\Controllers\ProfileController::getIndex ( )

Returns a view with the user's profile form for editing.

Author
[A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
Since
[v1.0]
Returns
View

Definition at line 27 of file ProfileController.php.

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  }
static locationsList()
Definition: Helper.php:94
App\Http\Controllers\ProfileController::postIndex ( )

Validates and stores the user's update data.

Author
[A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
Since
[v1.0]
Returns
Redirect

Definition at line 42 of file ProfileController.php.

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  }

The documentation for this class was generated from the following file: