Привет, у меня есть приложение laravel.Я использую make:auth()
для своей системы входа в систему и регистрации.По умолчанию регистрация автоматически переходит на домашнюю страницу.Теперь я хочу перенаправить свою страницу регистрации на себя, а затем добавить к ней флэш-сообщение.Не входить автоматическиЯ также добавил код сообщения Session flash
.Как я смогу достичь этого?это мой код ниже.Может кто-нибудь помочь мне разобраться в этом?Любая помощь очень ценится. 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><a href="#">Home</a></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" /> <a href="">Terms and Condition</a>
</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