Last active
May 26, 2018 16:22
-
-
Save kamerk22/4ffe185b2418158d1c09f6117732fc0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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\API\v1\Users; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Validator; | |
use App\Entities\Models\User; | |
class UserController extends Controller | |
{ | |
public function store(Request $request) | |
{ | |
// validate incoming request | |
$validator = Validator::make($request->all(), [ | |
'email' => 'required|email|unique:users', | |
'name' => 'required|string|max:50', | |
'password' => 'required' | |
]); | |
if ($validator->fails()) { | |
Session::flash('error', $validator->messages()->first()); | |
return redirect()->back()->withInput(); | |
} | |
// finally store our user | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment