diff --git a/app/Activity/MailService.php b/app/Activity/MailService.php new file mode 100644 index 0000000..969836e --- /dev/null +++ b/app/Activity/MailService.php @@ -0,0 +1,7 @@ +validate([ + "name" => "required", + "email" => "required|email|unique:users", + "password" => "required|min:6", + ]); + + if($res) { + $user = $request->only(["name", "password", "email"]); + $response = UserRepository::create($user); + return $response; + } else { + return response()->json([ + "message" => "User already exists!" + ], 400); + } + } + + public function login (Request $request) { + return "Logando"; + } +} diff --git a/app/Mail/UserEmail.php b/app/Mail/UserEmail.php new file mode 100644 index 0000000..a472ebd --- /dev/null +++ b/app/Mail/UserEmail.php @@ -0,0 +1,33 @@ +view('view.name'); + } +} diff --git a/app/Repository/UserRepository.php b/app/Repository/UserRepository.php new file mode 100644 index 0000000..65c15af --- /dev/null +++ b/app/Repository/UserRepository.php @@ -0,0 +1,26 @@ +save(); + + return response()->json([ + "message" => "User was created with success!!", + ], 201); + + } catch(Exception $ex) { + return response()->json([ + "message" => $ex, + ], 400); + } + } + + public static function findUser() { + + } +} \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index c641ca5..8cc80fd 100644 --- a/routes/api.php +++ b/routes/api.php @@ -16,3 +16,26 @@ Route::middleware('auth:api')->get('/user', function (Request $request) { return $request->user(); }); + +Route::prefix('v1')->group(function () { + + Route::prefix('auth')->group(function () { + Route::post('register', 'UserController@register'); + Route::post('login', 'UserController@login'); + }); + + /** + * Need to create the SlangController to + * replace the function hardcoded to controller function + */ + + Route::prefix('slang')->group(function () { + Route::get('/{name?}', function ($name = "") { + return "retun slang! ".$name; + }); + Route::post('/', function () { + return "add new slang"; + }); + }); + +}); \ No newline at end of file