I created a new Controller UsersController
and set the routes as mentioned below . Now I am trying to access this URL ( http://localhost/ecom/users/signin )
but it is showing nothing but a blank white screen. There is nothing in console and source of this page.I am using Resource Controller and Laravel 5.2.
PS: If anything needed more just mention in comments.
Routes.php
Route::resource('users', 'UsersController');
Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');
StoreController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use View;
class UsersController extends Controller
{
public function __construct(){
parent::__construct();
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return View::make('users.newaccount');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make(Input::all(), User::$rules);
if($validator->passes()){
$user = new User;
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = Input::get('password');
$user->save();
return Redirect::to('users/signin')->with('message','Thank you for creating new account.Sign in now');
}
return Redirect::to('users/newaccount')->with('message','Something went wrong!')->withErrors($validator)->withInput();
}
public function getSignin(){
return View::make('users.signin');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
public function getSignout(){
Auth::logout();
return Redirect::to('users/signin')->with('message','Signouted!');
}
/*public function postSignin(){
if(Auth::attempt(array('name' => Input::get('name'), 'email' => Input::get('email'), 'password'=> 'Input::get('password')))){
return Redirect::to('/')->with('message','Thanks for signin');
}
return Redirect::to('users/singin')->with('message','Was Incorrect DATA!');
} */
}
Signin View:
{!! Form::open(array('url' => 'users/signin' , 'method' => 'post')) !!}
<div class="form-group">
<label for="username">User Name:</label>
<input type="username" class="form-control" name="name" id="name">
</div>
<div class="form-group">
<label for="username">Password:</label>
<input type="username" class="form-control" name="password" id="name">
</div>
<button type="submit" class="btn btn-default">Sign IN</button>
{!! Form::close() !!}
Not sure why the comment is got deleted but you can move your routes above the resources, and it should work.
Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');
Route::resource('users', 'UsersController');
In your route put
Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');
over
Route::resource('users', 'UsersController');
like this
Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');
Route::resource('users', 'UsersController');
I know this is hella old but I think its because you are calling the Validator, Redirect and Auth classes without using it at the top...
add:
use Validator;
use Auth;
use Response;
to the top of your controller.
Check .htaccess. Options +ExecCGI addhandler x-httpd-php5-cgi .php Options -MultiViews DirectoryIndex index.php <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On RewriteBase / # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f #RewriteRule ^ index.php [L] RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.