2016-05-30 05:50:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Http\Requests\API\ProfileUpdateRequest;
|
|
|
|
use App\Models\User;
|
|
|
|
use Hash;
|
|
|
|
|
|
|
|
class ProfileController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Update the current user's profile.
|
|
|
|
*
|
|
|
|
* @param ProfileUpdateRequest $request
|
|
|
|
*
|
2016-08-03 10:42:11 +00:00
|
|
|
* @throws \RuntimeException
|
2016-08-03 10:42:39 +00:00
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
2016-05-30 05:50:59 +00:00
|
|
|
*/
|
|
|
|
public function update(ProfileUpdateRequest $request)
|
|
|
|
{
|
|
|
|
$data = $request->only('name', 'email');
|
|
|
|
|
2017-04-29 02:55:41 +00:00
|
|
|
if ($request->password) {
|
|
|
|
$data['password'] = Hash::make($request->password);
|
2016-05-30 05:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return response()->json(auth()->user()->update($data));
|
|
|
|
}
|
|
|
|
}
|