mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
73 lines
1.9 KiB
PHP
Executable file
73 lines
1.9 KiB
PHP
Executable file
<?php
|
|
/**
|
|
* This controller handles user profile editing
|
|
* the Snipe-IT Asset Management application.
|
|
*
|
|
* PHP version 5.5.9
|
|
* @package Snipe-IT
|
|
* @version v1.0
|
|
*/
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Image;
|
|
use Input;
|
|
use Redirect;
|
|
use App\Models\Location;
|
|
use View;
|
|
use Auth;
|
|
use App\Helpers\Helper;
|
|
|
|
class ProfileController extends Controller
|
|
{
|
|
/**
|
|
* User profile page.
|
|
*
|
|
* @return View
|
|
*/
|
|
public function getIndex()
|
|
{
|
|
// Get the user information
|
|
$user = Auth::user();
|
|
$location_list = Helper::locationsList();
|
|
return View::make('account/profile', compact('user'))->with('location_list', $location_list);
|
|
}
|
|
|
|
/**
|
|
* User profile form processing page.
|
|
*
|
|
* @return Redirect
|
|
*/
|
|
public function postIndex()
|
|
{
|
|
|
|
// Grab the user
|
|
$user = Auth::user();
|
|
|
|
// Update the user information
|
|
$user->first_name = e(Input::get('first_name'));
|
|
$user->last_name = e(Input::get('last_name'));
|
|
$user->website = e(Input::get('website'));
|
|
$user->location_id = e(Input::get('location_id'));
|
|
$user->gravatar = e(Input::get('gravatar'));
|
|
$user->locale = e(Input::get('locale'));
|
|
|
|
if (Input::file('avatar')) {
|
|
$image = Input::file('avatar');
|
|
$file_name = $user->first_name."-".$user->last_name.".".$image->getClientOriginalExtension();
|
|
$path = public_path('uploads/avatars/'.$file_name);
|
|
Image::make($image->getRealPath())->resize(84, 84)->save($path);
|
|
$user->avatar = $file_name;
|
|
}
|
|
|
|
if (Input::get('avatar_delete') == 1 && Input::file('avatar') == "") {
|
|
$user->avatar = null;
|
|
}
|
|
|
|
if ($user->save()) {
|
|
return Redirect::route('profile')->with('success', 'Account successfully updated');
|
|
}
|
|
return Redirect::back()->withInput()->withErrors($user->getErrors());
|
|
}
|
|
}
|