diff options
author | Mateja <mail@matejamaric.com> | 2020-10-27 23:17:19 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-10-27 23:17:19 +0100 |
commit | a3d432a6a0710261149fdaecdc2a5a62a82fe303 (patch) | |
tree | 7045451baab059a7ee5c630ba79e59d90e61d25e /app/Http/Controllers/PagesController.php | |
parent | 70af943af67e05656f8000a832ef7f27b4db4e6f (diff) | |
download | yota-laravel-a3d432a6a0710261149fdaecdc2a5a62a82fe303.tar.gz yota-laravel-a3d432a6a0710261149fdaecdc2a5a62a82fe303.zip |
Validator::make and html5 required
Diffstat (limited to 'app/Http/Controllers/PagesController.php')
-rw-r--r-- | app/Http/Controllers/PagesController.php | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index 3955254..5041f05 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -7,6 +7,9 @@ use App\Models\Post; use function dd; use function redirect; +use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\Redirect; + class PagesController extends Controller { public function index(Request $request) @@ -19,8 +22,6 @@ class PagesController extends Controller return view('pages.sponsoring'); } - //-------------------------------------- - public function news(Request $request) { $news = Post::all(); @@ -51,8 +52,6 @@ class PagesController extends Controller public function reserveForm(Request $request) { - //dd($request->input('modes')); - $validatedData = $request->validate([ 'scall' => 'required|alphanum', 'sdate' => 'required|date', @@ -67,38 +66,36 @@ class PagesController extends Controller 'phone' => ['required', 'regex:/^[0-9 ]+$/'], ]); -/* - $table->id(); - $table->boolean('approved')->default(false); - $table->unsignedBigInteger('specialCall'); - $table->dateTime('fromTime'); - $table->dateTime('toTime'); - $table->string('frequencies', 255); - $table->string('modes', 255); - $table->string('operatorCall'); - $table->string('operatorName'); - $table->string('operatorEmail'); - $table->string('operatorPhone', 50); - $table->integer('qso')->default(0); - $table->timestamps(); - $table->foreign('specialCall')->references('id')->on('special_calls'); -*/ - return redirect('reserve')->with('status', 'Reservation submitted.'); } - /** - * undocumented function - * - * @return void - */ public function loginForm(Request $request) { - $validatedData = $request->validate([ + $rules = [ 'email' => 'required|email', 'password' => 'required', - ]); - return redirect('login')->with('status', 'Submitted.'); + ]; + + $messages = [ + 'email.required' => 'Your email address is required.', + 'password.required' => 'Your password is required.', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + //return redirect('login') + return Redirect::back() + ->withErrors($validator) + ->withInput(); + } + + //$validatedData = $request->validate([ + //'email' => 'required|email', + //'password' => 'required', + //]); + //return redirect('login')->with('status', 'Submitted.'); + return Redirect::back()->with('status', 'Submitted.'); } |