Laravel 5.3 Session store not set on request - php

I have a Laravel project and I'm getting the following error and tried other questions asked before but i can't understand the problem. plz anybody guide me.
RuntimeException in C:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Http\Request.php line 905:
My routes.php file is here:
Route::group(['middleware' => ['web']], function () {
// default public route
Route::get('/', 'DashboardController#index');
// Rediret for Login Page
Route::get('/loginmsg', 'LoginMessageController#index');
// dashboard route
Route::get('dashboard/index', 'DashboardController#index');
});
//Route::get('/service/get/login','App\Http\Controllers\Auth\LoginMessageController#index')->name('xyz');
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('register', 'DashboardController#index');
});
Here's my register.blade.php
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Register</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}">
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}">
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">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>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation">
#if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i> Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection

Related

Laravel- Show errors on the login page when login credentials are wrong

I am new to Laravel. I am designing an login page and I want to show the errors on login page itself when the login credentials are wrong. I haven't done anything in controller. I am using the inbuilt Laravel function-Auth. Here is my view code given below:
<div class="card">
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('login') }}" aria-label="{{ __('Login') }}">
#csrf
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>
#if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</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{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
#if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> {{ __('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>
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
</div>
</div>
</form>
</div>
Controller Redirection:
Redirect::back()->withErrors(['errormsg', 'Try Again']);
Blade file:
#if($errors->any())
<h4>{{$errors->first()}}</h4>
#endif
Use this code and check.
if(Auth::attempt($user_data))
{
return redirect('/');
}
else
{
return redirect()->back()->withErrors(['error','Wrong Login Details']);
}
and put this code in login blade file.
#if($errors->any())
<h4>{{$errors->first()}}</h4>
#endif

Laravel Login route not working - submit button doesn't work

I am implementing authentication in my Laravel application, the register and logout routes are working perfectly fine, but the login form is not working. I'm not getting any error, but when I click the logi button it doesn't go anywhere.
Here is my login.blade.php :
#extends('layouts.app')
#section('title', 'Login')
#section('content')
<form class="form-horizontal form-material" id="loginform" method="POST" action="{{ route('login') }}>
#csrf
<h3 class="text-center m-b-20">Sign In</h3>
<div class="form-group ">
<div class="col-xs-12">
<input required="" id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" placeholder="Enter your Email" name="email" value="{{ old('email') }}" required autofocus> </div>
#if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
<div class="form-group">
<div class="col-xs-12">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" placeholder="Enter your Password" required>
#if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<div class="d-flex no-block align-items-center">
<div class="custom-control custom-checkbox">
<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 class="ml-auto">
<i class="fas fa-lock m-r-5"></i>{{ __('Forgot Your Password?') }}
</div>
</div>
</div>
</div>
<div class="form-group text-center">
<div class="col-xs-12 p-b-20">
<button class="btn btn-block btn-info btn-rounded" type="submit">{{ __('Login') }}</button>
</div>
</div>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
Don't have an account? <b>Sign Up</b>
</div>
</div>
</form>
#endsection
These are my login routes:
$this->get('admin/login', 'Auth\LoginController#showLoginForm')->name('login');
$this->post('admin/login', 'Auth\LoginController#login');
Does anyone know where I messed up?
You can try implementing the standard auth routing wrapped in a prefix to give you want you want:
Route::group(['prefix' => 'admin'], function () {
Auth::routes();
});
That way you do not have to worry about the route names being different from the docs :)

Laravel can't render view with form and token

I'm trying to render the view with the form reset password and laravel can't do it. Don't have errors but view is all white. If i change the view to other with a simple h1 laravel render it.
So, I guess the problem is with the token.
The route is this:
Route::get('/password/reset/{token}','Auth\AdminResetPasswordController#showResetForm')->name('admin.password.reset');
The controller function this:
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.reset-admin')->with(
['token' => $token, 'email' => $request->email]
);
}
And the view file is at
/resources/views/auth/passwords/reset-admin.blade.php
Thanks a lot.
At the end of the render process execute this function:
public function handleShutdown()
{
if (! is_null($error = error_get_last()) && $this->isFatal($error['type'])) {
$this->handleException($this->fatalExceptionFromError($error, 0));
}
}
Blade content:
#extends('backend.public.includes.head')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">ADMIN Reset Password</div>
<div class="panel-body">
#if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
#endif
<form class="form-horizontal" role="form" method="POST" action="{{ route('admin.password.request') }}">
{{ csrf_field() }}
<input type="hidden" name="token" value="{{ $token }}">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
#if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Reset Password
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
Extrainfo:
Take the scripts, but not render the form.
Error on error.loc
2017/07/14 11:19:35 [error] 5048#5048: *1 FastCGI sent in stderr: "PHP message: PHP Warning: require(/home/vagrant/Code/name/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/Code/name/bootstrap/autoload.php on line 17
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /home/vagrant/Code/name/public/index.php:0
PHP message: PHP 2. require() /home/vagrant/Code/name/public/index.php:22
If i put something like alskdaslkd on the view, it render it.
SOLVED
The problem is i use extend to head (where i have all the scripts) but in /layouts/default is where i define my "structure" with #yield('content') so if i put #extends('backend.public.layouts.default') on the top of the blade, i can use #section('content')

Validation is not working on Registration & Login form

I've following this Blog for multi table authentication. I downloaded the project as it is and run the project. Everything works but validation is not working. Now message showing while I post an empty form.
Here is the code:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password_confirmation">
#if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i>Register
</button>
</div>
</div>
</form>
According to the code error should be shown. I don't understand why its not working.
There is no validation rules or incorrect validation rules in your post controller.

Laravel 5.2: How to add a register page?

I am using Laravel 5.2,
and I use php artisan make:auth to make register page and login page.
Now, I would want to make two separated register pages,which used by two roles,seller and buyer ,
the two register pages named seller-register.blade.php and buyer-register.blade.php,
in view,add a item named userType,respectively corresponding seller and buyer,like this:
seller-register.blade.php
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Register</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/seller-register') }}">
{!! csrf_field() !!}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<label class="col-md-4 form-control-label">User Type</label>
<div class="col-md-6">
<label class="c-input c-radio">
<input id="userType" name="userType" type="radio" value="1" checked>
<span class="c-indicator"></span>
seller
</label>
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password_confirmation">
#if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i>Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
Question:
How to modify controller and other something?

Categories