From 4b92a7928ec6634dff4ca066af0a43ad1cfb3c46 Mon Sep 17 00:00:00 2001 From: Mateja Date: Tue, 20 Oct 2020 23:56:05 +0200 Subject: Learning about forms, POST, validation and AJAX in Laravel. --- app/Http/Controllers/PagesController.php | 8 ++++++++ resources/views/pages/reserve.blade.php | 5 +++++ routes/web.php | 1 + 3 files changed, 14 insertions(+) diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index c65e821..fcdfba9 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Post; +use function dd; +use function redirect; class PagesController extends Controller { @@ -47,6 +49,12 @@ class PagesController extends Controller return view('pages.reserve'); } + public function reserveForm(Request $request) + { + //dd($request->input('modes')); + return redirect('reserve')->with('status', 'Reservation submitted.'); + } + //public function services() //{ ////$title = 'Some title'; diff --git a/resources/views/pages/reserve.blade.php b/resources/views/pages/reserve.blade.php index a9b7879..a3a2519 100644 --- a/resources/views/pages/reserve.blade.php +++ b/resources/views/pages/reserve.blade.php @@ -1,6 +1,11 @@ @extends('layouts.app') @section('content') + @if (session('status')) +
+ {{ session('status') }} +
+ @endif
@csrf diff --git a/routes/web.php b/routes/web.php index b3912ab..cbbbc27 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,6 +36,7 @@ Route::get('/gallery', [PagesController::class, 'gallery'])->name('gallery'); Route::get('/sponsoring', [PagesController::class, 'sponsoring'])->name('sponsoring'); Route::get('/activities', [PagesController::class, 'activities'])->name('activities'); Route::get('/reserve', [PagesController::class, 'reserve'])->name('reserve'); +Route::post('/reserve', [PagesController::class, 'reserveForm'])->name('reserveForm'); Route::get('/login', [PagesController::class, 'login'])->name('login'); -- cgit v1.2.3