I am doing simple registration page in laravel 5.1 but got error.these are the files associated to it.
Authcontroller.php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
/**
* 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, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
// protected $loginPath = '/login';
//protected $redirectPath = '/';
protected function getRegister()
{
return view('register');
}
protected function getLogin()
{
return view('login');
}
protected function signme(Request $request)
{
print_r($request->all());
$validator = Validator::make(
array(
'first_name'=>$request->first_name
'last_name'=>$request->last_name
),array(
"first_name" => 'required',
"last_name" +> 'required'
)
);
if($validator->fails()){
return redirect('signup')->withError($validator)->withInput();
}else{
echo"this is not gd";
}
}
}
This is my authcontroller where it is showing errors.
<h1>signupform</h1>
<div class="signup-form">
{!! Form::open(array('url'=>'signme')) !!}
{!! Form::text('first_name','',array('class'=>'formtext','id'=>"first_name","placeholder"=>'First Name'))!!}<br><br>
{!! Form::text('last_name','',array('class'=>'formtext','id'=>"last_name","placeholder"=>'Last Name'))!!}<br><br>
{!! Form::text('email','',array('class'=>'formtext','id'=>"email","placeholder"=>'Email address'))!!}<br><br>
{!! Form::password('password','',array('class'=>'formtext','id'=>"password","placeholder"=>'password'))!!}<br><br>
{!! Form::password('c_password','',array('class'=>'formtext','id'=>"c_password","placeholder"=>'Confirm Password'))!!}<br><br>
{!!Form::submit('signup')!!}
{!! Form::close() !!}
</div>
This is my register blade where we are getting attributes from here. when i am running the code in local server apache it is giving this error.
FatalErrorException in AuthController.php line 100: syntax error, unexpected ''last_name'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'**
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire