Created
September 21, 2025 22:51
-
-
Save NandoKstroNet/9f5c9a3a5cf0f44dfcd9200b6669e5a8 to your computer and use it in GitHub Desktop.
Sessao 4 - Laravel Primeiros Passos (Registro): https://codeexperts.com.br
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Acessar Painel Eventos</title> | |
| @vite(['resources/css/app.css', 'resources/js/app.js']) | |
| </head> | |
| <body> | |
| <div class="w-full h-full absolute flex items-center justify-center"> | |
| <div class="max-w-3xl rounded border border-gray-300 p-4 shadow"> | |
| <div class="w-96 text-center"> | |
| <h2 class="text-xl font-bold mb-6">Acessar Meus Eventos</h2> | |
| </div> | |
| <form action="{{ route('register.store') }}" method="POST"> | |
| @csrf | |
| <div class="w-96 mb-6"> | |
| <label for="name" class="block mb-2">Nome Completo</label> | |
| <input type="name" name="name" | |
| class="w-full rounded outline-none border border-gray-300 p-2 focus:border-gray-900 focus:ring transition duration-300 ease-in-out" | |
| id="name" placeholder="Seu nome..." value="{{ old('name') }}" /> | |
| @error('name') | |
| <div class="p-2 border border-red-900 bg-red-400 text-red-900 rounded mb-6"> | |
| {{ $message }} | |
| </div> | |
| @enderror | |
| </div> | |
| <div class="w-96 mb-6"> | |
| <label for="email" class="block mb-2">E-mail</label> | |
| <input type="email" name="email" | |
| class="w-full rounded outline-none border border-gray-300 p-2 focus:border-gray-900 focus:ring transition duration-300 ease-in-out" | |
| id="email" placeholder="Seu email..." value="{{ old('email') }}" /> | |
| @error('email') | |
| <div class="p-2 border border-red-900 bg-red-400 text-red-900 rounded mb-6"> | |
| {{ $message }} | |
| </div> | |
| @enderror | |
| </div> | |
| <div class="w-96 mb-6"> | |
| <label for="password" class="block mb-2">Senha</label> | |
| <input type="password" name="password" | |
| class="w-full rounded outline-none border border-gray-300 p-2 focus:border-gray-900 focus:ring transition duration-300 ease-in-out" | |
| id="password" placeholder="Sua senha..." /> | |
| @error('password') | |
| <div class="p-2 border border-red-900 bg-red-400 text-red-900 rounded mb-6"> | |
| {{ $message }} | |
| </div> | |
| @enderror | |
| </div> | |
| <div class="w-96 mb-6"> | |
| <label for="password_confirmation" class="block mb-2">Confirmar Senha</label> | |
| <input type="password" name="password_confirmation" | |
| class="w-full rounded outline-none border border-gray-300 p-2 focus:border-gray-900 focus:ring transition duration-300 ease-in-out" | |
| id="password_confirmation" placeholder="Sua senha..." /> | |
| @error('password_confirmation') | |
| <div class="p-2 border border-red-900 bg-red-400 text-red-900 rounded mb-6"> | |
| {{ $message }} | |
| </div> | |
| @enderror | |
| </div> | |
| <button | |
| class="px-4 py-2 rounded border border-green-900 bg-green-600 hover:bg-green-900 text-white font-bold transition duration-300 ease-in-out"> | |
| Cadastrar | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
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\Auth; | |
| use App\Http\Controllers\Controller; | |
| use App\Http\Requests\Auth\RegisterRequest; | |
| use App\Models\User; | |
| use Illuminate\Http\Request; | |
| class RegisterController extends Controller | |
| { | |
| public function index() | |
| { | |
| return view('auth.register'); | |
| } | |
| public function store(RegisterRequest $request) | |
| { | |
| $data = $request->validated(); | |
| $data['password'] = bcrypt($data['password']); | |
| User::create($data); | |
| return redirect()->route('login'); | |
| } | |
| } |
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\Requests\Auth; | |
| use Illuminate\Foundation\Http\FormRequest; | |
| class RegisterRequest extends FormRequest | |
| { | |
| public function authorize(): bool | |
| { | |
| return true; | |
| } | |
| public function rules(): array | |
| { | |
| return [ | |
| 'name' => ['required', 'string'], | |
| 'email' => ['required', 'string', 'email', 'unique:users'], | |
| 'password' => ['required', 'string', 'min:8', 'confirmed'], | |
| ]; | |
| } | |
| } |
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 | |
| //... | |
| Route::get('/register', [\App\Http\Controllers\Auth\RegisterController::class, 'index'])->name('register'); | |
| Route::post('/register', [\App\Http\Controllers\Auth\RegisterController::class, 'store'])->name('register.store'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment