dimanche 26 octobre 2014

Laravel withinput double redirect


Vote count:

0




I am new to laravel and I am a bit confused about some code. I am working on validating a registration form. The problem is that after submitting the form the input is gone (yes I am using ->withinput). I redirect from the routes.php to the controller and then I redirect back to the view but the input is gone.


Usercontroller:



class UsersController extends \BaseController {

protected $user;

public function __construct(User $user)
{
$this->user = $user;
}
public function index()
{
$users = $this->user->all();
return View::make('templates.login');
}

public function store()
{
$input = Input::all();

if( ! $this->user->fill($input)->isValid())
{
return Redirect::back()->withInput()->withErrors($this->user->messages)->with('action', 'register');
}
//$this->user->save();

}


}


routes.php



Route::get('/', function()
{
return View::make('index');

//$users = DB::table('Users')->get();
//return $users;

});

Route::filter('checkLogin', function()
{


if(Input::GET('email') != ""){ //register

return Redirect::to('register')->withinput();

}
});


Route::post('/login', ['before'=>'checkLogin', 'uses'=>'SessionsController@store', 'as' => 'sessions.store']); //login
Route::get('logout', 'SessionsController@destroy');
Route::get('register', 'UsersController@store');


asked 1 min ago







Laravel withinput double redirect

Aucun commentaire:

Enregistrer un commentaire