syntax error, unexpected 'layouts' (T_STRING), expecting ')' (View: C:\xampp7\htdocs\shopping\resources\views\auth\register.blade.php) - laravel

ican not open to page "register.blade.php" when I click to register itt alert this error
syntax error, unexpected 'layouts' (T_STRING), expecting ')' (View: C:\xampp7\htdocs\shopping\resources\views\auth\register.blade.php) I can open page login.blade.php
my code in app.blade.php::
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
#if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#endif

There is a problem with your Register helper function, you are missing ')
<button type="submit" class="btn btn-primary">
{{ __('Register}}
</button>
Change to
<button type="submit" class="btn btn-primary">
{{ __('Register')}}
</button>

register.blade.php::
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
#csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
#error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="new-password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register}}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection

Related

Laravel 8 How to restrict user login if email is not verified

I am using Bootstrap Starter template package in Laravel 8 that replaces Tailwind CSS framework with Bootstrap CSS framework.
https://packagist.org/packages/shahvirag/laravel-ui-bootstrap
The problem I'm having is that user can sign in after registration without needing to verify account through email. How can I restrict his access until the email is not verified?
I have followed the steps and tried using routes middleware, but there is no such file in App\Http\Controllers\PagesController;
Route::get('/',[PagesController::class, 'index'])->name('users')->middleware('verified'); // this does not work
Any help?
routes/web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PagesController;
Route::get('/', function () {
return view('main');
});
Route::middleware(['auth'])->group(function() {
Route::get('/home', function() {
return view('home');
})->name('home');
Route::get('/user/profile', function() {
return view('profile');
})->name('profile');
});
Route::get('/',[PagesController::class, 'index'])->name('users')->middleware('verified');
resources/views/auth/login.blade.php
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<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>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<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>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
#if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
#endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
To use verified middleware, your user model should implement MustVerifyEmail
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
// ...
}
Try this instead
Route::get('/',[PagesController::class, 'index'])->name('users')->middleware(['auth', 'verified']);
You can use the method included with the User model:
$user->hasVerifiedEmail()
Or in the routes middleware(['verified'])

Login form in Laravel is giving the error 419 Page Expired

It used to work somoothly, then I added Sociallite and then it some point it broke the default login with email and password.
Now every time I login with username and password I get the error "419 Page Expired" and it's literally diving me crazy because I have tried everything, with no luck.
View login.blade.php:
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<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>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<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>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
#if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
#endif
</div>
</div>
</form>
Route web.php:
Route::post('login', [
'as' => '',
'uses' => 'Auth\LoginController#login'
]);
I searched the web and found some ppl talking about clearing cash, clearing cookies, checking cash and storage permissions, clearing SESSION_DOMAIN and I did all, but it's still the same.
Please anyone is still facing such issue in Larvel 7?

SQLSTATE[HY000]: General error: 1364 Field 'isAdmin' doesn't have a default value

SQLSTATE[HY000]: General error: 1364 Field 'isAdmin' doesn't have a default value (SQL: insert into users (name, email, password, updated_at, created_at) values (user, user123#gmail.com, $2y$10$hL36LXvdO/0m6PcAtZ1Zvurr5fg6HYX/v9hFTQLPBjYMlWpc3Fkv., 2020-04-18 13:25:15, 2020-04-18 13:25:15))
I can't put data when i click button register
file register.blade.php:
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
#csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
#error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="new-password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register')}}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
I think you should make your isAdmin field nullable or set default value:
$table->integer('isAdmin')->nullable();
or,
$table->integer('isAdmin')->default(0);
I happens because Because your isAdmin column is not nullable & when you add a new user data, you don't give any value for isAdmin Column...Here you have Two Solution either in your migration or when you create a user then give it's value either 0 or 1..
Or add a new migration where make this column nullable or set it a default value for this..
$table->boolean('isAdmin')->nullable();
Or set a default value
$table->boolean('isAdmin')->default(0);

Laravel: cascading model login and registration using bootstrap

I am trying to make a cascaded login and registration model using bootstrap.
when I click on sign in button the model pop up which is fine but login field is not working. Registration button is working. Again click on Login button the fields appear. Here is the screenshots and code
<a href="#" class="nav-link" data-toggle="modal" data-target="#exampleModal">
<img src="public/img/sign-in-icon.png" class="img-sign-in img-responsive"></a></li>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<!-- Nav tabs -->
<ul class="nav nav-tabs md-tabs tabs-2">
<li class="active">
<a class="nav-link active" data-toggle="tab" href="#login-form" role="tab"><i class="fas fa-user mr-1"></i>
Login</a>
</li>
<li>
<a class="nav-link" data-toggle="tab" href="#registration-form" role="tab"><i class="fas fa-user-plus mr-1"></i>
Register</a>
</li>
</ul>
<!--
<li class="nav-item">
Register
</li> -->
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="tab-content">
<div id="login-form" class="tab-pane fade in active">
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<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>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<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>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
#if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
#endif
</div>
</div>
</form>
</div>
<div id="registration-form" class="tab-pane fade">
<form action="/">
<div class="form-group">
<label for="name">Your Name:</label>
<input type="text" class="form-control" id="name" placeholder="Enter your name" name="name">
</div>
<div class="form-group">
<label for="newemail">Email:</label>
<input type="email" class="form-control" id="newemail" placeholder="Enter new email" name="newemail">
</div>
<div class="form-group">
<label for="newpwd">Password:</label>
<input type="password" class="form-control" id="newpwd" placeholder="New password" name="newpwd">
</div>
<button type="submit" class="btn btn-default">Register</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Does anybody please know, what is wrong with the code?

How can I get it to validate my inputfield

The inputfield dosn't get validated it make a postrequest anyway wether or not the validations is valid
I have watched and followed serial youtube vidos, without any lock.
I have also tried to read the documentation but I couldn't find the error
MY Controller:
public function changepassword(Request $request)
{
$request->validate([
'passwordA' => 'string', 'min:8', 'same:passwordB',
'passwordB' => 'string', 'min:8',
]);
}
My view:
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-header">Profil</div>
<div class="card-body">
<form method="POST" action="userprofile">
#csrf
<div class="form-group row">
<label for="username" class="col-sm-2 col-form-label">Username</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="username" placeholder="{{ $user->email }}" readonly>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" placeholder="{{ $user->firstname }} {{$user->surname}}" readonly>
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-sm-2 col-form-label">Phonenumber</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="phone" placeholder="{{ $user->telephonenr }}" readonly>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<label class="col-sm-12 col-form-label">Rest password</label>
</div>
</div>
<div class="form-group row">
<label for="passwordA" class="col-sm-2 col-form-label">New-Password</label>
<div class="col-sm-10">
<input type="password" class="form-control #error('passwordA') is-invalid #enderror" id="passwordA" name="PasswordA">
#error('passwordA')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="passwordB" class="col-sm-2 col-form-label">Type again</label>
<div class="col-sm-10">
<input type="password" class="form-control #error('passwordB') is-invalid #enderror" id="passwordB" name="PasswordB">
#error('passwordB')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<button type="submit" class="btn btn-primary">save</button>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
I was expected to validate the input and when I dosn't fit to the validating criteria the it should show the validation error

Resources