Error message not displaying on front-end laravel fortify - laravel

I'm trying to use fortify to create a recovery password page, where it asks for the user email and it should display an error message whenever the user tries to enter an email that is not valid, but the problem here is that the error message is only appearing on the server side and not on the page as it should. If I don't use bootstrap class in the error span it works, but I would like to know if there's any other way to solve this.
Here's the form:
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-50">
<form class="login100-form validate-form" action="{{route('password.request')}}" method="post">
#csrf
<span class="login100-form-title p-b-33">
Reset your password
</span>
#if(session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
#endif
<div class="wrap-input100 validate-input" data-validate = "Valid email is required: ex#abc.xyz">
<input class="input100" type="text" name="email" placeholder="Email">
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
#error('email')
<span class="invalid-feedback is-invalid" role="alert">
<strong>{{$message}}</strong>
</span>
#enderror
</div>
<div class="container-login100-form-btn m-t-20">
<button class="login100-form-btn" type="submit">
Send email
</button>
</div>
</form>
</div>
</div>
</div>
And this is where I think the problem might be:
#error('email')
<span class="invalid-feedback is-invalid" role="alert">
<strong>{{$message}}</strong>
</span>
#enderror

Related

Laravel 8 Image source not readable, on Intervention Image resize (Shared hosting)

I'm using Laravel 8. I was working on my machine (locally), after deploying it on the Shared hosting (my case Bluehost), I have moved the project to the root of my hosting, And I created a subdomain to my Laravel project, and I moved the public folders file to the subdomain folder.
I have executed the php artisan storage:link, everything works fine, even the images are uploaded, but the problem is when I use the Intervention Image to resize the image it shows
Intervention\Image\Exception\NotReadableException
Image source not readable
The code:
$imageName = $request['image']->store('uploads/brand', 'public');
Intervention\Image\Facades\Image::make(public_path("storage/{$imageName}"))->fit(1024, 1024)->save();
I have tried some solutions, but no result, the error kept the same
The solutions that I tried:
1- config/filesystems.php
'links' => [
base_path('/public_html/storage') => storage_path('app/public'),
],
2- I tried to specify the public path manually.
3- https://stackoverflow.com/a/39971026/5862126
the error is
Intervention\Image\Exception\NotWritableException
Can't write image data to path (/home4/ctwotec3/laravel_market/public/uploads/4386300.jpg)
Edited 1:
HTML Form code
#extends('layouts.app')
#section('content')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="container">
<form action="/brand" enctype="multipart/form-data" method="POST">
{{ csrf_field() }}
<div class="card">
<div class="card-header">
<h1 class="text-center">New Brand</h1>
</div>
<div class="card-body">
<div class="col-10 offset-1">
{{-- Name English --}}
<div class="row">
<div class="row mb-3">
<label for="name_en" class="col-md-4 col-form-label text-md-end">Name English</label>
<div class="col-md-6">
<input id="name_en" type="text"
class="form-control #error('name_en') is-invalid #enderror" name="name_en"
value="{{ old('name_en') }}" autocomplete="name_en" autofocus>
#error('name_en')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
{{-- Name Kurdish --}}
<div class="row">
<div class="row mb-3">
<label for="name_ku" class="col-md-4 col-form-label text-md-end">Name Kurdish</label>
<div class="col-md-6">
<input id="name_ku" type="text"
class="form-control #error('name_ku') is-invalid #enderror" name="name_ku"
value="{{ old('name_ku') }}" autocomplete="name_ku" autofocus>
#error('name_ku')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
{{-- Name Arabic --}}
<div class="row">
<div class="row mb-3">
<label for="name_ar" class="col-md-4 col-form-label text-md-end">Name Arabic</label>
<div class="col-md-6">
<input id="name_ar" type="text"
class="form-control #error('name_ar') is-invalid #enderror" name="name_ar"
value="{{ old('name_ar') }}" autocomplete="name_ar" autofocus>
#error('name_ar')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
{{-- Single image --}}
<div class="row">
<div class="row mb-3">
<label for="image"
class="col-md-4 col-form-label text-md-end">{{ __('Item image') }}</label>
<div class="col-md-6">
<input id="chooseFile" type="file" class="form-control" name="image" #error('image')
is-invalid #enderror accept=".jpg,.jpeg,.png">
#error('image')
<strong style="color: red">{{ $message }}</strong>
#enderror
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<button class="btn btn-primary mt-3 mb-3 float-end w-75 ">submit</button>
</div>
</form>
</div>
#endsection
Edited 2: here is the path of the uploaded image on the server, that the Intervention Image can't read it
/home4/ctwotec3/laravel_market/public/storage/uploads/brand/r0kBFdXcxCg59WKIwmNsIwq16g30mWs4LZLxWSeT.jpg

How to Handle Laravel error messages in vue?

I know I did something wrong here, but how do you handle error messages of Laravel in vue template?... is there a way of bypassing the #error of the laravel Blade templating
this is the vue component file (fileComponent.vue)
<template>
<div class="row my-2">
<div class="col-md-2 font-weight-bold pt-2">Grade:</div>
<div class="col-md-10">
<select name="grade" class="form-control #error('grade') is-invalid #enderror" v-model="selected_grade" #change="onChange($event)">
<option v-for="grade in grading" :key="grade.id" :value="grade.name">{{grade.name}}</option>
</select>
#error('grade')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="row my-3" v-if="subjects !== null">
<div class="col-md-3">
<div class="card shadow">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold">Subjects:</h6>
</div>
<div class="card-body">
<div class="custom-control custom-checkbox" v-for="subject in subjects" :key="subject.id">
<input type="checkbox" class="custom-control-input #error('subjects') is-invalid #enderror" name="subjects[]" :id="subject.name" :value="subject.name"/>
<label class="custom-control-label" :for="subject.name">{{subject.name}}</label>
</div>
#error('subjects')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
</div>
</div>
</div>
</template>
This is Shown on the page instead of error message

bootstrap 4 and laravel 5.6 not showing error under input field

I am using laravel 5.6 and have the follwing in blade file:
<form method="POST" action="/review">
#csrf
{{ $errors->first('nickname') }}
<input type="hidden" name="book_id" value="{{ request()->route('id') }}">
<div class="form-group">
<label for="nickname">nickname:</label>
<input type="text" name="nickname" class="form-control {{ $errors->has('nickname') ? 'is-ivalid' : ''}}" id="nickname">
#if($errors->has('nickname'))
<div class="invalid-feedback" role="alert">
<strong>{{ $errors->first('nickname') }}</strong>
</div>
#endif
</div>
<div class="form-group">
<label for="review">comment:</label>
<textarea name="review" class="form-control"></textarea>
#if($errors->has('review'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('review') }}</strong>
</span>
#endif
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
as you see in the third line I added {{$errors->first('nickname')}} just to make sure it has output and it does but just not showing the output under the input field.
how to solve this? why it happened?
You have a typo in {{ $errors->has('nickname') ? 'is-ivalid' : ''}} should be is-invalid.

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!

How can I check if user is connected in order to display phone number Laravel

I have a little problem which I can't find a convenient solution to it. I have a button in the user profile page which on click will display the user phone number which was initially hidden. It is working quite alright but what I want is that, in order for the phone number to be revealed, the user must be signed in if not it will redirect the user to the login page with a flash message saying "You must be logged in, in order to view this number"
In my Profile Details View file I have this
<span class="job-is ft" id="more" onclick="$('.details').slideToggle(function(){$('#more').html($('.details').is(':visible')?'Cacher le numero':'Voir le numero');});">Voir le numero</span>
<div class="extra-job-info details" style="display:none">
<p style="text-align: center; padding: 10px; font-size: 45px;">
<i class="la la-phone"></i> {{ $profiledetail->phone }}
</p>
</div>
In my user Controller I have this
public function jobberDetails($id) {
$profiledetail = User::find($id);
return view('Users.profileDetail', compact('profiledetail'));
}
My web file
// Route qui permet d'afficher,le profil d'un Jobbeur
Route::get('/jobber/profiledetails/{id}','UserController#jobberDetails')->where(array('id' => '[0-9]+'))->name('profileDetails');
In my login view
#section('content')
<section>
<div class="block remove-bottom">
<div class="container">
<div class="row">
#include('Flash/flash')
<div class="col-lg-12">
#if (session('confirmation-success'))
<div class="alert alert-success">
{{ session('confirmation-success') }}
</div>
#endif
#if (session('confirmation-danger'))
<div class="alert alert-danger">
{!! session('confirmation-danger') !!}
</div>
#endif
<div class="account-popup-area signin-popup-box static">
<div class="account-popup">
<span>Connexion</span>
<form method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="cfield{{ $errors->has('email') ? ' has-error' : '' }}">
<input type="email" placeholder="Email" name="email" value="{{ old('email') }}" required autofocus />
<i class="la la-user"></i>
#if ($errors->has('email'))
<span class="help-block" style="float: left;">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
<div class="cfield{{ $errors->has('password') ? ' has-error' : '' }}">
<input type="password" placeholder="********" name="password" required />
<i class="la la-key"></i>
#if ($errors->has('password'))
<span class="help-block" style="float: left;">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
<p class="remember-label">
<input type="checkbox" id="cb1" name="remember" {{ old('remember') ? 'checked' : '' }}><label for="cb1">Remember me</label>
</p>
Forgot Password?
<button type="submit">Login</button>
</form>
<div class="extra-login">
<span>Or</span>
<div class="login-social">
<a class="fb-login" href="#" title=""><i class="fa fa-facebook"></i></a>
<a class="tw-login" href="#" title=""><i class="fa fa-twitter"></i></a>
</div>
</div>
</div>
</div><!-- LOGIN POPUP -->
</div>
</div>
</div>
</div>
</section>
#endsection

Resources