sending error message laravel required inputs - php

so i wanted to make validation to my register form so i made all my inputs required so i can test my validation that it works or not, so this is what i used in my controller
$Message = [
'required' => 'This input is required',
];
$validator = Validator::make($request->all(), [
'name' => 'required',
'email' => 'required',
'password' => 'required',
'UserName' => 'required',
'Phone' => 'required',
'SSN' => 'required',
'SDT' => 'required',
'Country' => 'required',
'InsuranceAmount' => 'required',
'City' => 'required',
'Location' => 'required'
], $Message);
if ($validator->fails()) {
return redirect('/admin/users/create')
->withErrors($validator)
->withInput();
}
$user = new User;
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = bcrypt(Input::get('password'));
$user->UserName = input::get('UserName');
$user->Phone = input::get('Phone');
$user->SSN = input::get('SSN');
$user->SDT = input::get('SDT');
$user->Country = input::get('Country');
$user->City = input::get('City');
$user->Location = input::get('Location');
$user->save();
return Redirect::to('/admin/users')->with('message', 'User Created');
Now if theres no errors it works fine and redirect to user list, but if a input is empty it will just redirect to the creation page whict is what i wanted but the problem is it won't send the error message with the redirect i tried dd the validator and it has all the messages fine heres my view
<form class="form-horizontal" role="form" method="POST" action="{{ Route('userstore') }}">
{!! csrf_field() !!}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">الاسم</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('UserName') ? 'has-error' : ''}}">
<label class="col-md-4 control-label">اسم المستخدم</label>
<div class="col-md-6">
<input type="text" class="form-control" name="UserName" value="{{ old('UserName') }}">
#if ($errors->has('UserName'))
<span class="help-block">
<strong>{{ $errors->first('UserName') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group {{$errors->has('Phone') ? 'has-error' : ''}}">
<label class="col-md-4 control-label">رقم الجوال</label>
<div class="col-md-6">
<input type="text" class="form-control" name="Phone" value="{{old('Phone')}}">
#if ($errors->has('Phone'))
<span class="help-block">
<strong>{{ $errors->first('Phone') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group {{$errors->has('SSN') ? 'has-error' : ''}}">
<label class="col-md-4 control-label">الرقم الوطني</label>
<div class="col-md-6">
<input type="text" class="form-control" name="SSN" value="{{old('SSN')}}">
#if ($errors->has('SSN'))
<span class="help-block">
<strong>{{ $errors->first('SSN') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group {{$errors->has('SDT') ? 'has-error' : ''}}">
<label class="col-md-4 control-label">نوع الوثيقة</label>
<div class="col-md-6">
<input type="text" class="form-control" name="SDT" value="{{old('SDT')}}">
#if ($errors->has('SDT'))
<span class="help-block">
<strong>{{ $errors->first('SDT') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group {{$errors->has('Country') ? 'has-error' : ''}}">
<label class="col-md-4 control-label">الدولة</label>
<div class="col-md-6">
<select class="form-control" name="Country">
<option>الاردن</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">المدينة</label>
<div class="col-md-6">
<select class="form-control" name="City" >
<option>عمان</option>
</select>
</div>
</div>
<div class="form-group {{$errors->has('Location') ? 'has-error' : ''}}">
<label class="col-md-4 control-label">اسم الشارع</label>
<div class="col-md-6">
<input type="text" class="form-control" name="Location" value="{{old('Location')}}">
#if ($errors->has('Location'))
<span class="help-block">
<strong>{{ $errors->first('Location') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }} ltr-input">
<label class="col-md-4 control-label">البريد الإلكتروني</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' : '' }} ltr-input">
<label class="col-md-4 control-label">كلمة المرور</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' : '' }} ltr-input">
<label class="col-md-4 control-label">تأكيد كلمة المرور</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 pull-right">
<i class="fa fa-btn fa-user"></i> تسجيل
</button>
</div>
</div>
</form>
and btw this is laravel 5.1

I fix the problem by upgrading my project from laravel 5.1 to 5.5

Related

how can i get the values of some inputs from database after select option in dropdown

I'm building an HTML form that contains all information about clients, and the others information, so I would when I choose the name of the client that is in the dropdown (select options that contain all name of clients ) the other input fields like (address, tel, email) should be filled automatically.
I don't know what I have to use ajax or jquery and how to use it.
this is my view:
#extends('layouts.master')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-11">
<div class="panel panel-default">
<div class="panel-heading">Création de commandes</div>
<div class="panel-body">
<form id="form2" class="form-horizontal" method="POST" action="{{url('gestion_commandes/create')}}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('nomp') ? ' has-error' : '' }}">
<label for="nomp" class="col-md-1 control-label">Client</label>
<div class="col-md-5">
<select name="nomclient" id="nomclient" class="form-control dynamic" data-dependent="organisme" required autofocus>
<option>--Select--</option>
#foreach ($clientscombos as $clientcombos)
<option value="{{$clientcombos->nom}}">{{$clientcombos->nom}} </option>
#endforeach
</select>
</div>
{{ csrf_field() }}
<label for="organisme" class="col-md-1 control-label">Organisme</label>
<div class="col-md-5">
<input id="organisme" type="text" class="form-control" name="organisme" value="{{$clientcombos->organisme}}" required autofocus>
#if ($errors->has('organisme'))
<span class="help-block">
<strong>{{ $errors->first('organisme') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('adresse') ? ' has-error' : '' }}">
<label for="adresse" class="col-md-1 control-label">Adresse</label>
<div class="col-md-5">
<input id="adresse" type="text" class="form-control" name="adresse" value="{{$clientcombos->adresse}}" autofocus>
#if ($errors->has('adresse'))
<span class="help-block">
<strong>{{ $errors->first('adresse') }}</strong>
</span>
#endif
</div>
<label for="emailp" class="col-md-1 control-label">E-Mail Address</label>
<div class="col-md-5">
<input id="emailp" type="email" class="form-control" name="emailp" placeholder="Saisir l'adresse email" required autofocus>
#if ($errors->has('emailp'))
<span class="help-block">
<strong>{{ $errors->first('emailp') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('adressep') ? ' has-error' : '' }}">
<label for="tel" class="col-md-1 control-label">Tel</label>
<div class="col-md-3">
<input id="tel" type="Tel" class="form-control" name="tel" value="{{$clientcombos->tel1}}" required autofocus>
#if ($errors->has('tel'))
<span class="help-block">
<strong>{{ $errors->first('tel') }}</strong>
</span>
#endif
</div>
<label for="tel2p" class="col-md-1 control-label">Tel2</label>
<div class="col-md-3">
<input id="tel2p" type="Tel" class="form-control" name="tel2p" value="+2126" required autofocus>
#if ($errors->has('tel2p'))
<span class="help-block">
<strong>{{ $errors->first('tel2p') }}</strong>
</span>
#endif
</div>
<label for="faxp" class="col-md-1 control-label">Fax</label>
<div class="col-md-3">
<input id="faxp" type="Tel" class="form-control" name="faxp" value="{{$clientcombos->fax}}" required autofocus>
#if ($errors->has('faxp'))
<span class="help-block">
<strong>{{ $errors->first('faxp') }}</strong>
</span>
#endif
</div>
</div>
<div class=" panel panel-success"> </div>
<div class=" panel panel-success"> </div>
<div class="form-group{{ $errors->has('daterecep') ? ' has-error' : '' }}">
<label for="commercial" class="col-md-1 control-label">Commercial</label>
<div class="col-md-3">
<select name="commercial" id="commercial" class="form-control" required autofocus>
<option>--Select--</option>
#foreach ($combocommerciaux as $combocommercial)
<option value="{{$combocommercial->name}}">{{$combocommercial->name}} </option>
#endforeach
</select>
</div>
<label for="datereception" class="col-md-1 control-label">Date de réception</label>
<div class="col-md-3">
<input id="datereception" type="date" class="form-control" name="datereception" placeholder="Saisir le nom complet" required autofocus>
#if ($errors->has('datereception'))
<span class="help-block">
<strong>{{ $errors->first('datereception') }}</strong>
</span>
#endif
</div>
<label for="dateprelev" class="col-md-1 control-label">Date de prélevement</label>
<div class="col-md-3">
<input id="dateprelev" type="date" class="form-control" name="dateprelev" placeholder="Saisir le nom complet" required autofocus>
#if ($errors->has('dateprelev'))
<span class="help-block">
<strong>{{ $errors->first('dateprelev') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('commercial') ? ' has-error' : '' }}">
<label for="savedby" class="col-md-9 control-label">Enregistrée par </label>
<div class="col-md-3">
<input id="savedby" type="text" class="form-control" name="savedby" value="{{Auth::user()->name}}" required autofocus>
#if ($errors->has('savedby'))
<span class="help-block">
<strong>{{ $errors->first('savedby') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('nbrrowsol') ? ' has-error' : '' }}">
<label for="nbrrowsow" class="col-md-1 control-label">Sol </label>
<div class="col-md-3">
<input id="nbrrowsol" type="number" class="form-control" name="nbrrowsol" required autofocus>
#if ($errors->has('nbrrowsol'))
<span class="help-block">
<strong>{{ $errors->first('nbrrowsol') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('nbrroweau') ? ' has-error' : '' }}">
<label for="nbrroweau" class="col-md-1 control-label">Eau </label>
<div class="col-md-3">
<input id="nbrroweau" type="number" class="form-control" name="nbrroweau" required autofocus>
#if ($errors->has('nbrroweau'))
<span class="help-block">
<strong>{{ $errors->first('nbrroweau') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('nbrrowveg') ? ' has-error' : '' }}">
<label for="nbrrowveg" class="col-md-1 control-label">VEG </label>
<div class="col-md-3">
<input id="nbrrowveg" type="number" class="form-control" name="nbrrowveg" required autofocus>
#if ($errors->has('nbrrowveg'))
<span class="help-block">
<strong>{{ $errors->first('nbrrowveg') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('nbrrowbiof') ? ' has-error' : '' }}">
<label for="nbrrowbiof" class="col-md-1 control-label">Fertilisant </label>
<div class="col-md-3">
<input id="nbrrowbiof" type="number" class="form-control" name="nbrrowbiof" placeholder="Saisir l'adresse email" required autofocus>
#if ($errors->has('nbrrowbiof'))
<span class="help-block">
<strong>{{ $errors->first('nbrrowbiof') }}</strong>
</span>
#endif
</div>
<div class="col-md-6 control-label">
<button type="submit" class="btn btn-primary" onclick="location.href='{{url('gestion_regions/create')}}'" >Executer</button>
</div>
</div>
<div class="form-group{{ $errors->has('nbrrowmicair') ? ' has-error' : '' }}">
<label for="nbrrowmicair" class="col-md-1 control-label">Mic Air </label>
<div class="col-md-3">
<input id="nbrrowmicair" type="number" class="form-control" name="nbrrowmicair" required autofocus>
#if ($errors->has('nbrrowmicair'))
<span class="help-block">
<strong>{{ $errors->first('nbrrowmicair') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('nbrrowmiceau') ? ' has-error' : '' }}">
<label for="nbrrowmiceau" class="col-md-1 control-label">Mic Eau</label>
<div class="col-md-3">
<input id="nbrrowmiceau" type="number" class="form-control" name="nbrrowmiceau" required autofocus>
#if ($errors->has('nbrrowmiceau'))
<span class="help-block">
<strong>{{ $errors->first('nbrrowmiceau') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('nbrrowmicsurface') ? ' has-error' : '' }}">
<label for="nbrrowmicsurface" class="col-md-1 control-label">Mic Surface </label>
<div class="col-md-3">
<input id="nbrrowmicsurface" type="number" class="form-control" name="nbrrowmicsurface" placeholder="Saisir l'adresse email" required autofocus>
#if ($errors->has('nbrrowmicsurface'))
<span class="help-block">
<strong>{{ $errors->first('nbrrowmicsurface') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-success">
Enregistrer
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
this is controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Client;
class DynamicDependent extends Controller
{
public function comboboxclients()
{
$clientscombos = DB::select('select * from clients');
$combocommerciaux = DB::select('select * from commercials');
return view('gestion_commandes.create',['clientscombos' => $clientscombos , 'combocommerciaux' => $combocommerciaux]);
}
}
You have to:
1) Server-side: create another action which will fetch client data based on value from select(I suggest you using an client id as select value inside your template).
2) Client-side: add hook on select value change('change' event inside JS), which will send an AJAX request(containing selected value) to action created on step 1, and populate form inputs with received data.
That's pretty much it. Fell free to ask about specific implementation details, but keep in mind that no one will write code for you here, you have to do it yourself, but you'll be fine with this directions.

Laravel Second registration form

I'm working on laravel 5.4 i have 3 type of users and all of them working perfectly, 1 of them of course is admin and the 2 other is users and companies, users are using auth default login nd register form and there is no issue on that, what my issue is for companies to register i need a new form I made a blade for companies registration form and register controller for them in app/http/auth folder now form will loading and when I try to save the form it returns me this error:
FatalThrowableError in CompanyRegisterController.php line 54: Type error: Too few arguments to function App\Http\Controllers\Auth\CompanyRegisterController::create(), 0 passed and exactly 1 expected
My line 54 is:
protected function create(array $data)
this is my complete companyregistercontroller:
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class CompanyRegisterController extends Controller
{
/**
* Where to redirect users after registration.
*
* #var string
*/
protected $redirectTo = 'companies';
public function __construct() {
$this->middleware('guest:company');
}
protected function index()
{
return view('auth.company-register');
}
/**
* Get a validator for an incoming registration request.
*
* #param array $data
* #return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'company_name' => 'required|string|max:255',
'manager_name' => 'required|string|max:255',
'address' => 'required|string|max:255',
'username' => 'required',
'email' => 'required|string|email|max:255|unique:users',
'about' => 'sometimes|min:10|max:2000',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* #param array $data
* #return User
*/
protected function create(array $data)
{
return Company::create([
'company_name' => $data['company_name'],
'manager_name' => $data['manager_name'],
'address' => $data['address'],
'username' => $data['username'],
'about' => $data['about'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
UPDATE
My view codes
#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">Companies Register form <span style="float:right;" data-toggle="tooltip" data-placement="top" title="If you need to hire people click here."><i class="fa fa-building"></i> Company register</span></div>
<div class="panel-body">
<p>
<img src="{{ asset('images/signup-icon.png') }}" class="img-responsive img-circle regimg" alt="Register" >
</p>
<form class="form-horizontal" role="form" method="POST" action="{{ route('company.register.submit') }}">
{{ csrf_field() }}
<div class="row">
<div class="col-md-6">
<div class="form-group{{ $errors->has('company_name') ? ' has-error' : '' }}">
<label for="company_name" class="col-md-4 control-label"><i class="fa fa-user-circle"></i> Company Name</label>
<div class="col-md-8">
<input id="company_name" type="text" class="form-control" name="company_name" value="{{ old('company_name') }}" required autofocus>
#if ($errors->has('company_name'))
<span class="help-block">
<strong>{{ $errors->first('company_name') }}</strong>
</span>
#endif
</div>
</div>
</div><!-- end col-md-6 -->
<div class="col-md-6">
<div class="form-group{{ $errors->has('manager_name') ? ' has-error' : '' }}">
<label for="manager_name" class="col-md-4 control-label"><i class="fa fa-user-circle-o"></i> Manager Name</label>
<div class="col-md-8">
<input id="manager_name" type="text" class="form-control" name="manager_name" value="{{ old('manager_name') }}" required autofocus>
#if ($errors->has('manager_name'))
<span class="help-block">
<strong>{{ $errors->first('manager_name') }}</strong>
</span>
#endif
</div>
</div>
</div><!-- end col-md-6 -->
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group{{ $errors->has('address') ? ' has-error' : '' }}">
<label for="address" class="col-md-4 control-label"><i class="fa fa-address-book"></i> Address</label>
<div class="col-md-8">
<input id="address" type="text" class="form-control" name="address" value="{{ old('address') }}" required autofocus>
#if ($errors->has('address'))
<span class="help-block">
<strong>{{ $errors->first('address') }}</strong>
</span>
#endif
</div>
</div>
</div><!-- end col-md-6 -->
<div class="col-md-6">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label"><i class="fa fa-envelope"></i> E-Mail Address</label>
<div class="col-md-8">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
</div><!-- end col-md-6 -->
</div>
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
<label for="username" class="col-md-4 control-label"><i class="fa fa-birthday-cake"></i> username</label>
<div class="col-md-6">
<input id="username" type="text" class="form-control" name="username" value="{{ old('username') }}" autofocus>
#if ($errors->has('username'))
<span class="help-block">
<strong>{{ $errors->first('username') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('about') ? ' has-error' : '' }}">
<label for="about" class="col-md-4 control-label"><i class="fa fa-birthday-cake"></i> about</label>
<div class="col-md-6">
<input id="about" type="textarea" class="form-control" name="about" value="{{ old('about') }}" autofocus>
#if ($errors->has('about'))
<span class="help-block">
<strong>{{ $errors->first('about') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label"><i class="fa fa-key"></i> 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">
<label for="password-confirm" class="col-md-4 control-label"><i class="fa fa-unlock-alt"></i> Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-success btn-bg btn-block">
<i class="fa fa-registered"></i> Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
Any idea why this doesn't work?

Laravel 5.3 Session store not set on request

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

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