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?
Related
I used hyn/tenancy https://tenancy.dev/docs/hyn/5.4 and created an application like this: https://www.seismicpixels.com/creating-a-laravel-saas-framework-part-6/
At the moment I'm having the problem that I'm trying to setup a registration controller for users within the tenant. I tried doing this with a second public function in the registration controller
protected function createuser(array $data)
{
print_r($data);
die();
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
The showRegistrationForm() function is:
/**
* Show the application registration form.
*
* #return \Illuminate\Http\Response
*/
public function showRegistrationForm()
{
return view('auth.registeruser');
}
The error I'm facing is (as far as i do understand), says that there's no array, which could be selected as $data . I tried using the die() like above but array $data isn't going through.
I also tried using the standard registration page which is
#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="{{ route('register.users') }}">
{{ 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') }}" required autofocus>
#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') }}" required>
#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">
<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>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
and here's my web.php where the registration routes are shown, but I don't think the problem is within here because i'm getting an error out of the function, so the routing works?
// Register Routes
Route::get('register', 'Auth\RegisterUserController#showRegistrationForm')->name('register.user');
Route::post('registeruser', 'Auth\RegisterController#createuser')->name('register.users');
I hope somebody can help me with this error (probably on my side 🙈)
Thanks in advance!
Try This:
protected function createuser(Request $request)
{
print_r($request->name);
die();
return User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
}
You are passing the $data as parameter but not definig it in you route:
try this hope it will help you!
Your registers.users should use Auth\RegisterController#register method. createuser is called inline and receives $request->all()
Btw, default name for the function is create(), no createuser (if you don't want to modify register method)
How to implement remember me in laravel 6 login
So far I have done this following laravel 6 documentation.
In my Users table I have a column called remember_token to store the value.
This is my login controller,
public function login(Request $request,$remember)
{
$input = $request->all();
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
$fieldType = filter_var($request->email, FILTER_VALIDATE_EMAIL) ? 'username' : 'username';
if(auth()->attempt(array($fieldType => $input['email'], 'password' => $input['password'],$remember)))
{
return redirect()->route('home');
}else{
return redirect()->route('login')
->withFail(__('sentence.Login failed due to invalid credentials.'),'Email-Address And Password Are Wrong.');
}
}
And my login form as follows,
<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">{{ __('sentence.Username') }}</label>
<div class="col-md-6">
<input id="email" type="text" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" autocomplete="email" autofocus>
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<!-- <p>{{ trans('sentence.welcome')}}</p> -->
<!-- {{ __('sentence.welcome') }} -->
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('sentence.Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" 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">
{{ __('sentence.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">
{{ __('sentence.Login') }}
</button>
#if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('sentence.Forgot Your Password?') }}
</a>
#endif
</div>
</div>
</form>
but the mentioned code giving me following error,
Symfony\Component\Debug\Exception\FatalThrowableError
Too few arguments to function App\Http\Controllers\Auth\LoginController::login(), 1 passed and exactly 2 expected
Hi i have this laravel app. Im using the make:auth() for my login and registration system. By default the registration will automatically goes to /home page. Now, i want to redirect my register page to itself then add a flash message to it. Not automatically login. I also added the Session flash message code to it. How will i able to achieve this? this is my code below. Can someone help me figured this thing out?
Any help is muchly appreciated.TIA
app\http\controllers\auth\RegisterController.php :
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* #var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* 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, [
'firstName' => 'required|string|max:255',
'middleName'=> 'required|string|max:255',
'lastName'=> 'required|string|max:255',
'address'=> 'required|string|max:255',
'contactNumber'=> 'required|string|max:255',
'username'=> 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* #param array $data
* #return \App\User
*/
protected function create(array $data)
{
$membersNumber = time() . rand(10*45, 100*98);
Session::flash('success', 'You are successfully registered! Serapio.ph will review your submitted documents and will text you if you can login.');
return User::create([
'members_number'=>$membersNumber,
'first_name' => $data['firstName'],
'middle_name'=>$data['middleName'],
'last_name'=>$data['lastName'],
'address'=>$data['address'],
'contact_number'=>$data['contactNumber'],
'username'=>$data['username'],
'reference_person'=>$data['referencePerson'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
register.blade.php :
#extends('layouts.app')
#section('title', 'Register | Serapio.ph')
#section('content')
<!-- BREADCRUMBS -->
<div class="page-header">
<div class="container">
<h1 class="page-title pull-left">Register</h1>
<ol class="breadcrumb">
<li>Home</li>
<li class="active">Register</li>
</ol>
</div>
</div>
<!-- END BREADCRUMBS -->
<div class="container">
<div class="row">
<form class="form-horizontal" method="POST" action="{{ route('register') }}">
<div class="col-md-6 form-horizontal">
<!-- REGISTRATION FORM -->
<br>
<h2 class="section-heading">Member's Sign Up Info</h2>
{{ csrf_field() }}
#if (session('success'))
<p class="alert alert-success">{{ Session::get('success') }}</p>
#endif
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="firstName" name="firstName" value="{{ old('firstName') }}" placeholder="First Name" />
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="middleName" name="middleName" value="{{ old('middleName') }}" placeholder="Middle Name" />
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="lastName" name="lastName" value="{{ old('lastName') }}" placeholder="Last Name" />
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="address" name="address" value="{{ old('address') }}" placeholder="Address" />
<span class="input-group-addon"><i class="fa fa-map-pin"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="contactNumber" name="contactNumber" value="{{ old('contactNumber') }}" placeholder="Contact Number" />
<span class="input-group-addon"><i class="fa fa-phone-square"></i></span>
</div>
</div>
</div>
</div>
<div class="col-md-6 form-horizontal" style='margin-top:95px;'>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="referencePerson" name="referencePerson" value="" placeholder="Reference Person (Optional)" />
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" id="username" name="username" value="{{ old('username') }}" placeholder="Username" />
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="control-label sr-only">Email</label>
<div class="col-sm-12">
<div class="input-group">
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}" placeholder="Email">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="control-label sr-only">Password</label>
<div class="col-sm-12">
<div class="input-group">
<input type="password" class="form-control" id="password" name="password" value="" placeholder="Password">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="form-group">
<label for="password2" class="control-label sr-only">Repeat Password</label>
<div class="col-sm-12">
<div class="input-group">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required placeholder="Repeat Password">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label style="color:red;">Note* Upload Seaman's Book/Students ID<br><i>Please upload file using PDF or JPG</i></label>
<input type="file" name="pdf" />
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<input type="checkbox" name="checkbox" /> Terms and Condition
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="pull-right btn btn-success btn-lg"><i class="fa fa-check-circle"></i> Create Account</button>
</div>
</div>
</div>
</form>
<!--<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" method="POST" action="{{ route('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') }}" required autofocus>
#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') }}" required>
#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">
<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>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>-->
</div>
</div>
#endsection
I created a registration form using make:auth command in Laravel 5.5. Its working alright but not showing errors when validation fails. I've checked many times that code to display errors exists in template but still getting this error.
Template Location:
resources/views/mybladetemplate
Method in Controller:
protected function validator(array $data)
{
return Validator::make($data, [
'field1' => 'required|string|max:255',
'emailField' => 'required|string|email|max:255|unique:users',
'fieldPwd' => 'required|string|min:6|confirmed',
'anotherfield' => 'string'
]);
}
RegistersUsers Trait:
public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
$this->guard()->login($user);
return $this->registered($request, $user)
?: redirect($this->redirectPath());
}
Registeration Form:
<form class="form-horizontal" method="POST" action="{{ route('register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('field1') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Field Name</label>
<div class="col-md-6">
<input id="field1" type="text" class="form-control" name="field" value="{{ old('field1') }}" required autofocus>
#if ($errors->has('field1'))
<span class="help-block">
<strong>{{ $errors->first('field1') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('emailField') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="emailField" type="email" class="form-control" name="emailField" value="{{ old('emailField') }}" required>
#if ($errors->has('emailField'))
<span class="help-block">
<strong>{{ $errors->first('emailField') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<label for="anotherfield" class="col-md-4 control-label">Another Field</label>
<div class="col-md-6">
<input id="anotherfield" type="text" class="form-control" name="anotherfield" value="{{ old('anotherfield') }}" />
</div>
</div>
<div class="form-group{{ $errors->has('fieldPwd') ? ' has-error' : '' }}">
<label for="fieldPwd" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="fieldPwd" type="password" class="form-control" name="fieldPwd" required>
#if ($errors->has('fieldPwd'))
<span class="help-block">
<strong>{{ $errors->first('fieldPwd') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<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>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
Use this simple code in your blade to show all of the errors in a ul li structure :
#if($errors->any())
#foreach ($errors->all() as $error)
<div class="alert alert-warning" dir="rtl">
<ul>
<li>{!! $error !!}</li>
</ul>
</div>
#endforeach
#endif
I have installed laravel authentication(Scaffolding) to my Point of Sale application , registration form was working fine BUT I created an Admin middle ware and I restricted the /register to admin only , I can get the view from my admin panel when admin is logged in but when I submit data it sends nothing to database.
PS: If any thing else is need just mention in comments.
Registration View:
#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 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>
</div>
</div>
</div>
</div>
</div>
#endsection
Routes:
Route::group(['middleware' => 'web'], function () {
Route::get('/', function () {
return view('welcome');
});
Route::auth();
Route::get('/home', 'HomeController#index');
Route::get('/register', function(){
return view('auth.register');
})->middleware('isAdmin');
});
HomeController:
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
return view('home');
}
}
Try using fillable in User.php
For Example:
If you want to store name, email and password, make sure you have
protected $fillable = ['name', 'email', 'password'];
in your User.php