Created
March 24, 2018 13:24
-
-
Save tiggreen/3fcdef08db486b330441f068f90d43f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
class SettingsController extends Controller | |
{ | |
public function __construct() | |
{ | |
$this->middleware('auth:api'); | |
} | |
public function updateUser(Request $request) | |
{ | |
$this->validate($request, [ | |
'name' => 'required|max:255', | |
'email' => 'required|email|max:255|unique:users,email,' . $request->user()->id, | |
]); | |
$request->user()->update([ | |
'name' => $request->name, | |
'email' => $request->email, | |
]); | |
return response()->json($request->user()->toArray()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment