空白的白色屏幕Laravel 5.2

时间:2016-03-18 17:25:30

标签: php laravel laravel-routing laravel-5.2

我创建了一个新的Controller UsersController并设置了如下所述的路由。现在我正在尝试访问此网址( http://localhost/ecom/users/signin ),但它只显示空白屏幕。此页面的控制台和源代码中没有任何内容。我正在使用资源控制器和Laravel 5.2。

PS:如果需要更多内容,请在评论中提及。

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!');
    } */


}

登录查看:

     {!! 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() !!}

4 个答案:

答案 0 :(得分:1)

不确定为什么评论被删除了,但你可以将你的路线移到资源之上,它应该有效。

Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');

Route::resource('users', 'UsersController');

答案 1 :(得分:0)

在你的路线中

Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');

结束

Route::resource('users', 'UsersController');
像这样

Route::get('users/signin', 'UsersController@getSignin');
Route::get('users/newaccount', 'UsersController@getSignup');
Route::resource('users', 'UsersController');

答案 2 :(得分:0)

我知道这是hella old,但我认为它是因为你在不使用它的情况下调用Validator,Redirect和Auth类...

添加:

use Validator;
use Auth;
use Response;

到控制器的顶部。

答案 3 :(得分:0)

检查.htaccess。 #!/bin/bash USAGE="Usage: $0 [N days] (list|size|delete) [path, default /tmp/hive]" if [ ! "$1" ]; then echo $USAGE exit 1 fi AGO="`date --date "$1 days ago" "+%F %R"`" echo "# Will search for files older than $AGO" if [ ! "$2" ]; then echo $USAGE exit 1 fi INPATH="${3:-/tmp/hive}" echo "# Will search under $INPATH" case $2 in list) hdfs dfs -ls -R "$INPATH" |\ awk '$1 ~ /^[^d]/ && ($6 " " $7) < '"\"$AGO\"" ;; size) hdfs dfs -ls -R "$INPATH" |\ awk '$1 ~ /^[^d]/ && ($6 " " $7) < "'"$AGO"'" { sum += $5 ; cnt += 1} END { print cnt, "Files with total", sum, "Bytes"}' ;; delete) hdfs dfs -ls -R "$INPATH" |\ awk '$1 ~ /^[^d]/ && ($6 " " $7) < "'"$AGO"'" {print $8}' | \ xargs hdfs dfs -rm -skipTrash ;; *) echo $USAGE exit 1 ;; esac