How to update v-model data in laravel blade file in edit form - laravel

I have a single file for creating and updating the category data.
while creating category, i am using v-model in title to also create slug in the same form.
works well when creating but i am facing issue with update / edit form part.
below is my code :
<input class="form-input mt-1 block w-full" name="name" v-model="title" v-on:keyup="getSlug" placeholder="Category Title" value="{{ $category->name ?? '' }}">
adding whole blade file code for reference:
#extends('layouts.backend.app')
#php
if(isset($record) && $record != null){
$edit = 1;
} else {
$edit = 0;
}
#endphp
#section('content')
<section id="app" class="container mx-auto">
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold">
#if($edit) Edit #else Create #endif Category Form
</h1>
Back
</div>
<div class="border rounded mt-8 p-8">
<form action="#if($edit) {{route('category.update', $record->id)}} #else {{route('category.store')}} #endif" method="POST">
#csrf
<label class="block mb-4">
<span class="text-gray-700 font-bold">Name</span>
<input class="form-input mt-1 block w-full" name="name" v-model="title" v-on:keyup="getSlug" placeholder="Category Title" value="{{ $category->name ?? '' }}">
#error('name')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-4">
<span class="text-gray-700 font-bold">Slug</span>
<input
class="form-input mt-1 block w-full"
name="slug"
id="slug"
v-model="slug"
placeholder="Slug / Pretty URL">
#error('slug')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-8">
<span class="text-gray-700 font-bold">Banner</span>
<input
class="form-input mt-1 block w-full"
name="banner"
value="#if($edit) {{$record->banner}} #else https://source.unsplash.com/random #endif"
placeholder="Banner / URL">
</label>
<div class="flex justify-between">
<button class="px-4 py-2 border bg-gray-200 text-gray-900 rounded" type="submit">Submit</button>
<button class="px-4 py-2 border bg-red-400 text-white rounded" type="rest">Reset</button>
</div>
</form>
</div>
</section>
#endsection
as you can see the title input is use to create the slug on keyup event. now the given code don't use the data from database for pre populating the edit form title input field. because i am using v-model="title" which is in my app.js and is null at the moment.
How to either assign v-model="title" my current value from database.
This is not a vue component. its a laravel blade file. Kindly guide me for this.
Thanks

You can move the app.js code to the Blade view and populate title with the Blade expression
#extends('layouts.backend.app')
#php
if(isset($record) && $record != null){
$edit = 1;
} else {
$edit = 0;
}
#endphp
#section('content')
<section id="app" class="container mx-auto">
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold">
#if($edit) Edit #else Create #endif Category Form
</h1>
Back
</div>
<div class="border rounded mt-8 p-8">
<form action="#if($edit) {{route('category.update', $record->id)}} #else {{route('category.store')}} #endif"
method="POST">
#csrf
<label class="block mb-4">
<span class="text-gray-700 font-bold">Name</span>
<input class="form-input mt-1 block w-full" name="name" v-model="title" v-on:keyup="getSlug"
placeholder="Category Title" value="{{ $category->name ?? '' }}">
#error('name')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-4">
<span class="text-gray-700 font-bold">Slug</span>
<input class="form-input mt-1 block w-full" name="slug" id="slug" v-model="slug"
placeholder="Slug / Pretty URL">
#error('slug')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-8">
<span class="text-gray-700 font-bold">Banner</span>
<input class="form-input mt-1 block w-full" name="banner"
value="#if($edit) {{$record->banner}} #else https://source.unsplash.com/random #endif"
placeholder="Banner / URL">
</label>
<div class="flex justify-between">
<button class="px-4 py-2 border bg-gray-200 text-gray-900 rounded" type="submit">Submit</button>
<button class="px-4 py-2 border bg-red-400 text-white rounded" type="rest">Reset</button>
</div>
</form>
</div>
</section>
{{-- Place the script here, after closing the section with id of app --}}
<script>
const app = new Vue({
el: '#app',
data() {
return {
title: '{{ $category->name }}'
}
},
methods: {
getSlug() {
this.title = this.title.toLowerCase()
.replace(/ /g,'-')
.replace(/[^\w-]+/g,'');
}
}
});
</script>
#endsection
Hope this helps

In The End, I went back to the old style of doing things.
code as below:
getSlug() {
var title = document.getElementById('title').value;
document.getElementById('slug').value = title.replace(/\s+/g, '-').toLowerCase().trim();
},
and replaced v-model with id tag on the input field.

Related

syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) (View: .... \livewire\map-location.blade.php)

What is wrong? I checked many times, but when run there is an error in if else.
"syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) (View: D:\laragon\www\ta-atm\resources\views\livewire\map-location.blade.php)"
<div class="card-body">
<form #if ($isEdit) wire:submit.prevent="updateLocation" #else wire:submit.prevent="saveLocation" #endif>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="">Longitude</label>
<input wire:model="long" type="text" class="form-control"> #error('long') <small class="text-danger">{{ $message }}</small>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="">Latitude</label>
<input wire:model="lat" type="text" class="form-control"> #error('lat') <small class="text-danger">{{ $message }}</small>
</div>
</div>
</div>
<div class="form-group">
<label for="">Title</label>
<input wire:model="title" type="text" class="form-control"> #error('title') <small class="text-danger">{{ $message }}</small>
</div>
<div class="form-group">
<label for="">Description</label>
<input wire:model="description" class="form-control"> #error('description') <small class="text-danger">{{ $message }}</small>
</div>
<div class="form-group">
<label for="">Picture</label>
<input wire:model="image" type="file" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label> #error('image') <small class="text-danger">{{ $message }}</small>
</div>
#if ($image)
<img src="{{ $image->temporaryUrl() }}" class="img-fluid"> #endif #if ($imageUrl && !$image)
<img src="{{ asset('/storage/images/' . $imageUrl) }}" class="img-fluid"> #endif
</div>
<div class="form-group">
<button type="submit" class="btn btn-dark text-white btn-block">{{ $isEdit ? 'Update Location' : 'Submit Location' }}</button> #if ($isEdit)
<button wire:click="deleteLocation" type="submit" class="btn btn-danger text-white btn-block">Delete Location</button> #endif
</div>
</form>
</div>
</div>
</div>
</div>
Many of the Blade directives become specific if statements in the compiled view. In this case, you have #error() but no #enderror (and also no code to put between them to be shown when there is an error). See the #error directive documentation.

Missing required parameter for [Route: password.reset] [URI: reset-password/{token}]

Im trying to implement the fortify authentication.
When I want to reset the password it opens the route: reset-password. When I open the link it gives me an error message:
Missing required parameter for [Route: password.reset] [URI: reset-password/{token}]
i'm using the following versions:
php 8.0.2
Laravel Framework 8.32.1
npm 6.17.11
Anyone able to help me out with this ?
FortifyServiceProvider.php:
Fortify::loginView(function(){
return view( view: 'auth.login');
});
Fortify::registerView(function(){
return view( view: 'auth.register');
});
Fortify::requestPasswordResetLinkView(function(){
return view( view: 'auth.forgot-password');
});
Fortify::resetPasswordView(function($request){
return view('auth.reset-password', ['token' => $request]);
});
reset-password.blade.php
#extends('template')
#section('content')
<div class="container">
<div class="card login-card">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/img/login.jpg" alt="login" class="login-card-img">
</div>
<div class="col-md-7">
#if ($errors->any())
#foreach ($errors->all() as $error)
<h1>{{ $error }}</h1>
#endforeach
#endif
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="card-body">
<div class="brand-wrapper">
<img src="/img/logo.png" alt="logo" class="logo">
</div>
<p class="login-card-description">Reset password</p>
<form method="POST" action="{{ route('password.reset') }}">
#csrf
<input type="hidden" name="token" value="{{$request->route('token')}}">
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input type="email" name="email" id="email" class="form-control"
placeholder="Email address" value="{{request->email}}">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="new-password" placeholder="Password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password" placeholder="Confirm password">
</div>
<input name="login" id="login" class="btn btn-block login-btn mb-4" type="submit" value="Update">
</form>
<p class="login-card-footer-text">Don't have an account? <a href="{{ route('register') }}"
class="text-reset">Register here</a></p>
<nav class="login-card-footer-nav">
Terms of use.
Privacy policy
</nav>
</div>
</div>
</div>
</div>
#endsection
forgot-password.blade.php
#extends('template')
#section('content')
<div class="container">
<div class="card login-card">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/img/login.jpg" alt="login" class="login-card-img">
</div>
<div class="col-md-7">
#if ($errors->any())
#foreach ($errors->all() as $error)
<h1>{{ $error }}</h1>
#endforeach
#endif
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="card-body">
<div class="brand-wrapper">
<img src="/img/logo.png" alt="logo" class="logo">
</div>
<p class="login-card-description">Reset password</p>
#if(session('status'))
{{session('status')}}
#endif
<form method="POST" action="{{ route('password.request') }}">
#csrf
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input type="email" name="email" id="email" class="form-control"
placeholder="Email address">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<input name="login" id="login" class="btn btn-block login-btn mb-4" type="submit" value="Reset">
</form>
<p class="login-card-footer-text">Don't have an account? <a href="{{ route('register') }}"
class="text-reset">Register here</a></p>
<nav class="login-card-footer-nav">
Terms of use.
Privacy policy
</nav>
</div>
</div>
</div>
</div>
#endsection
register.blade.php
#extends('template')
#section('content')
<div class="container">
<div class="card login-card">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/img/login.jpg" alt="login" class="login-card-img">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="brand-wrapper">
<img src="/img/logo.png" alt="logo" class="logo">
</div>
<p class="login-card-description">Register a new account</p>
<form method="POST" action="{{ route('register') }}">
#csrf
<div class="form-group">
<label for="name" class="sr-only">Name</label>
<input id="name" type="text" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus placeholder="Name">
</div>
#error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email" placeholder="Email address">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="new-password" placeholder="Password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password" placeholder="Confirm password">
</div>
<input name="register" id="register" class="btn btn-block login-btn mb-4" type="submit" value="Register">
</form>
Forgot password?
<p class="login-card-footer-text">Alredy have an account? Login here</p>
<nav class="login-card-footer-nav">
Terms of use.
Privacy policy
</nav>
</div>
</div>
</div>
</div>
</div>
#endsection
login.blade.php
#extends('template')
#section('content')
<div class="container">
<div class="card login-card">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/img/login.jpg" alt="login" class="login-card-img">
</div>
<div class="col-md-7">
#if($errors->any())
#foreach ($errors->all() as $error)
<h1>{{ $error }}</h1>
#endforeach
#endif
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="card-body">
<div class="brand-wrapper">
<img src="/img/logo.png" alt="logo" class="logo">
</div>
<p class="login-card-description">Sign into your account</p>
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input type="email" name="email" id="email" class="form-control" placeholder="Email address">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="***********">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<input name="login" id="login" class="btn btn-block login-btn mb-4" type="submit" value="Login">
</form>
Forgot password?
<p class="login-card-footer-text">Don't have an account? Register here</p>
<nav class="login-card-footer-nav">
Terms of use.
Privacy policy
</nav>
</div>
</div>
</div>
</div>
#endsection
template.blade.php
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<main class="d-flex align-items-center min-vh-100 py-3 py-md-0">
#yield('content')
</main>
</div>
</body>
</html>
In reset-password.blade.php change the route password.reset to password. update like below
<form method="POST" action="{{ route('password.update') }}">
and this
<input type="email" name="email" id="email" class="form-control"
placeholder="Email address" value="{{request->email}}">
to this
<input type="email" name="email" id="email" class="form-control"
placeholder="Email address" value="{{$request->email}}">
you were missing the $ in request->email
change this ['token' => $request] to ['request' => $request] like below
Fortify::resetPasswordView(function($request){
return view('auth.reset-password', ['token' => $request]);
});
Hope it works

Redirect to registration bootstrap model in Laravel 6

I am using the following code in my controller for redirecting to login page if a guest user clicks button for uploading a product. Now I have created bootstrap model for login and registration. I want to pop-up the modal if user click button.
public function __construct()
{
$this->middleware('auth')->except('index', 'show');
}
Login and Register Button
#guest
<li class="list-inline-item">
<button type="button" class="btn btn-primary btn-outline-light" data-toggle="modal" data-target="#signIn" href="{{ route('login') }}">{{ __('Login') }}</button>
</li>
#if (Route::has('register'))
<li class="list-inline-item">
<button type="button" class="btn btn-primary btn-outline-light" data-toggle="modal" data-target="#signUp" href="{{ route('register') }}">{{ __('Register') }} </button>
</li>
#endif
Bootstrap Modal
<div class="modal" id="signIn">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">SignIn</h4>
<button type="button" class="close" data-dismiss="modal">
×
</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-group">
<label for="email" class="">{{ __('E-Mail Address') }}</label>
<input id="email" type="email" class="form-control" #error('email') is-invalid #enderror"
name="email" value="{{ old('email') }}" required autocomplete="email" autofocus />
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group">
<label for="password" class="">{{ __('Password') }}</label>
<input id="password" type="password"
class="form-control #error('password') is-invalid #enderror" name="password" required
autocomplete="current-password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">
Sign In
</button>
</div>
</form>
</div>
</div>
</div>
</div>

Laravel app displays wrong image source when deployed

My app works perfectly offline but when deployed, I didn't get to display images properly.
this is my store controller function
public function store(Request $request)
{
$contestant = new Contestant();
$contestant->name = $request->name;
$contestant->gender = $request->Gender[0];
$contestant->Occupation = $request->Occupation;
$contestant->Hobbies = $request->Hobbies;
$contestant->DOB = $request->DOB;
$contestant->Nationality = $request->Nationality;
$contestant->location = $request->location;
$contestant->About = $request->About;
$contestant->votes = 0;
$image = $request->photo;
$imagePath = $image->store('contestant', 'public');
$contestant->image = $imagePath;
// Image::make(public_path("storage/{$imagePath}"))->fit(1200, 1200);
// $contestant -> image = $imagePath;
$contestant->save();
return view('admin.home');
}
this is is how I display it in my blade
<a class="cardlink" href="{{ route('Contestant.index',$contestant -> id)}}">
<img class=" card-img-top " src="/storage/{{ $contestant -> image }}" alt="Card image cap">
</a>
EDIT
html code:
#foreach ($contestants as $contestant)
<div class="col-md-4">
<div class="card shadow contestant-card">
<a class="cardlink" href="{{ route('Contestant.index',$contestant -> id)}}">
<img class=" card-img-top " src="/storage/{{ $contestant -> image }}" alt="Card image cap"></a>
<div class="card-body">
<h5 class="card-title border-bottom pb-3"> <span class="text-dark"> Name:
</span><br>{{ $contestant -> name }}
{{-- <a href="#"
class="float-right d-inline-flex share"><i class="fa fa-share-alt text-primary"></i></a> --}}
</h5>
<p>
<span class="card-text">{{ $contestant -> Ocupation ?? $contestant -> gender }}</span> |
<span class="card-text"> {{ $contestant -> location }}.</span>
</p>
<input type="hidden" name="id" value="{{ $contestant -> id }}">
<button data-toggle="modal" data-target="#exampleModalCenter"
class="btn btn-lg btn-info btn-block">Vote</button>
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog"
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Vote for
{{ $contestant -> name }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
#csrf
#method('POST')
<div class="form-group">
<label for="cc-payment" class="control-label mb-1">contestant Name: </label>
<input id="cc-pament" name="cc-payment" type="text" class="form-control"
disabled value="{{ $contestant -> name }}">
</div>
<div class="form-group">
<label for="vote" class="control-label mb-1">Number of Votes: </label>
<select name="cc-vote" id="cc-vote" class="form-control"> Number of Votes
<option value="none" selected disabled> Select</option>
<option value="50">1 Vote for ₦50</option>
<option value="3000">20 Votes for ₦3000</option>
<option value="5000">40 Votes for ₦5000</option>
<option value="10000">100 Votes for ₦10,000</option>
<option value="20000">250 Votes for ₦20,000</option>
<option value="40000">550 Votes for ₦40,000</option>
<option value="100000">1,200 Votes for ₦100,000</option>
<option value="200000">2,500 Votes for ₦200,000</option>
</select>
</div>
<div class="form-group has-success">
<label for="cc-name" class="control-label mb-1">Name</label>
<input id="cc-name" name="cc-name" type="text" class="form-control cc-name">
<span class="help-block field-validation-valid" data-valmsg-for="cc-name"
data-valmsg-replace="true"></span>
</div>
<div>
<form action="{{ route('pay') }}" method="post" novalidate="novalidate">
<input type="hidden" name="email" value="otemuyiwca#gmail.com">
{{-- required --}}
<input type="hidden" name="orderID" value="345">
<input type="hidden" id="amount" name="amount" value="">
<input type="hidden" name="metadata"
value="{{ json_encode($array = ['id' => $contestant -> id,]) }}">
<input type="hidden" name="reference"
value="{{ Unicodeveloper\Paystack\Facades\Paystack::genTranxRef() }}">
{{-- required --}}
<input type="hidden" name="key" value="{{ config('paystack.secretKey') }}">
{{-- required --}}
{{ csrf_field() }} {{-- works only when using laravel 5.1, 5.2 --}}
<button id="payment-button" type="submit"
class="btn btn-lg btn-info btn-block">
<i class="fa fa-lock fa-lg"></i>
<span id="payment-button-amount">Pay</span>
<span id="payment-button-sending" style="display:none;">Sending…</span>
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</a>
</div>
</div>
The image is stored as contestant/dgfy563tgfFTjhhyyf6CTiihiDc5tCT.jpeg in my database but gives a broken image when displayed, when I inspect element with chrome, img src is "/storage//tmp/phptYYEv9

Catch ONLY the invalid credentials error in a login.blade Laravel

I am using the custom login controller from Laravel. I have the validation messages in a below the input fields.
Everything works fine.
What I want now is to show a message “incorrect credentials” ONLY when user or password are incorrect and in a different div. I mean, if other validation error triggers, this message should not be visible.
The errors->has(‘email’) array catches this error but also the rest, for instance, ‘the field is required’.
Does anybody know how to write a condition that only catches this ‘invalid credentials’ error message?
Below the template.
Thanks in advance for your help!
#extends ('layouts.default')
#section('content')
#if ($errors->has('email')) {{-- I want the credential error here, but only
for credential error is triggered --}}
<div class="warning">
<div class="input-icon">
<i style="font-size:1.5em; color:Tomato; margin-right:5px;" class="fas
fa-exclamation-triangle"></i>
</div>
<p>Usuario o contraseña incorrecta</p>
</div>
#endif
<main class="login-page">
<div class="contact login">
<div class="titulos">
<p>Ingresar</p>
<p>Soy nuevo</p>
</div>
<form method="post">
#csrf
<div class="input-group input-group-icon">
<input type="email" name="email" placeholder="Correo electrónico"
value="{{ old('email') }}" autofocus/>
<div class="input-icon">
<i class="fas fa-envelope"></i>
</div>
<span class="obligatorio" > {{ $errors->first('email') }}</span>
</div>
<div class="input-group input-group-icon">
<input type="password" name="contraseña"
placeholder="Contraseña"/>
<div class="input-icon">
<i class="fas fa-lock"></i>
</div>
<span class="obligatorio" >{{ $errors->first('contraseña') }}
<div class="input-group">
<input type="submit" value="Ingresar" />
<a href="{{ route('password.request') }}">Olvidé mi
contraseña</a>
</div>
<div>
<label>
<input type="checkbox" name="recordar" id="cbox1"
value="recordar" {{ old('recordar') ? 'checked' : '' }}>
<span>Recordar mi usuario</span>
</label>
</div>
</form>
</div>
</main>
#endsection
In an old beginner Project of mine I did it this way:
<div class="form-group{{ $errors->has('text') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">#lang('views/auth/login.username')</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control" name="name">
#if ($errors->has('text'))
<span class="help-block">
<strong>{{ $errors->first('text') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">#lang('views/auth/login.password')</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password">
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
And inside the Controller I just catched the Exceptions:
public function authenticate(Request $request)
{
try {
$this->ldapHelper->checkCredentials($request->name, $request->password);
$ldapUserData = $this->ldapHelper->getFormattedUserData(request('name'));
$this->sessionService->login($ldapUserData);
return redirect()->route('form.formular');
} catch (\Exception $e) {
return back()->withInput()->withErrors([
'message' => $e->getMessage(),
]);
}
}
Maybe it helps!

Resources