Laravel对任何请求都会抛出错误

时间:2016-09-15 09:05:48

标签: php laravel-5.2

我在Laravel中收到以下错误:

我几乎检查了每个文件。

Whoops, looks like something went wrong.

1/1
ErrorException in Grammar.php line 252:
Undefined index: Type
in Grammar.php line 252
at HandleExceptionshandleError('8', 'Undefined index: Type', '/home/vagrant/Code/dq/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php', '252', array('query' => object(Builder), 'sql' => array(), 'where' => array('column' => 'email', 'operator' => '=', 'value' => '6test@gmail.com', 'boolean' => 'and'))) in Grammar.php line 252
at GrammarcompileWheres(object(Builder), array(array('column' => 'email', 'operator' => '=', 'value' => '6test@gmail.com', 'boolean' => 'and'))) in Grammar.php line 75
at GrammarcompileComponents(object(Builder)) in Grammar.php line 51
at GrammarcompileSelect(object(Builder)) in MySqlGrammar.php line 38
at MySqlGrammarcompileSelect(object(Builder)) in Builder.php line 1514
at BuildertoSql() in Builder.php line 1583
at BuilderrunSelect() in Builder.php line 1569
at Builderget(array('*')) in Builder.php line 624
at BuildergetModels(array('*')) in Builder.php line 316
at Builderget(array('*')) in Builder.php line 286
at Builderfirst() in compiled.php line 1032
at EloquentUserProviderretrieveByCredentials(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf')) in compiled.php line 611
at SessionGuardattempt(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf'), false, false) in compiled.php line 572
at SessionGuardvalidate(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf')) in compiled.php line 564
at SessionGuardonce(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf'))
at call_user_func_array(array(object(SessionGuard), 'once'), array(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf'))) in compiled.php line 465
at AuthManager__call('once', array(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf'))) in IlluminateAuthAdapter.php line 39
at IlluminateAuthAdapterbyCredentials(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf')) in JWTAuth.php line 108
at JWTAuthattempt(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf')) in compiled.php line 6325
at Facade__callStatic('attempt', array(array('email' => '6test@gmail.com', 'password' => 'asdfasdfasdf'))) in AuthController.php line 17
at AuthControllerlogin(object(Request))
at call_user_func_array(array(object(AuthController), 'login'), array(object(Request))) in compiled.php line 9419
at ControllercallAction('login', array(object(Request))) in compiled.php line 9481
at ControllerDispatchercall(object(AuthController), object(Route), 'login') in compiled.php line 9461
at ControllerDispatcherIlluminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at PipelineIlluminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9938
at Pipelinethen(object(Closure)) in compiled.php line 9462
at ControllerDispatchercallWithinStack(object(AuthController), object(Route), object(Request), 'login') in compiled.php line 9449
at ControllerDispatcherdispatch(object(Route), object(Request), 'App\Http\Controllers\Auth\AuthController', 'login') in compiled.php line 8517
at RouterunController(object(Request)) in compiled.php line 8504
at Routerun(object(Request)) in compiled.php line 8218
at RouterIlluminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at PipelineIlluminate\Routing\{closure}(object(Request)) in compiled.php line 13400
at ShareErrorsFromSessionhandle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9953
at PipelineIlluminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at PipelineIlluminate\Routing\{closure}(object(Request)) in compiled.php line 11943
at StartSessionhandle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9953
at PipelineIlluminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at PipelineIlluminate\Routing\{closure}(object(Request)) in compiled.php line 13139
at AddQueuedCookiesToResponsehandle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9953
at PipelineIlluminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at PipelineIlluminate\Routing\{closure}(object(Request)) in compiled.php line 13076
at EncryptCookieshandle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9953
at PipelineIlluminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at PipelineIlluminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9938
at Pipelinethen(object(Closure)) in compiled.php line 8219
at RouterrunRouteWithinStack(object(Route), object(Request)) in compiled.php line 8210
at RouterdispatchToRoute(object(Request)) in compiled.php line 8200
at Routerdispatch(object(Request)) in compiled.php line 2419
at KernelIlluminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at PipelineIlluminate\Routing\{closure}(object(Request)) in compiled.php line 3286
at CheckForMaintenanceModehandle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9953
at PipelineIlluminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at PipelineIlluminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9938
at Pipelinethen(object(Closure)) in compiled.php line 2366
at KernelsendRequestThroughRouter(object(Request)) in compiled.php line 2350
at Kernelhandle(object(Request)) in index.php line 53

这里有什么问题?它会在每个请求上抛出错误。

AuthController.php:

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Tymon\JWTAuth\Facades\JWTAuth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AuthController extends Controller
{
    public function login(Request $request)
    {
        $credentials = $request->only('email', 'password');

        try {
            if (! $token = JWTAuth::attempt($credentials)) {
                return response()->json(['error' => 'invalid_credentials'], 401);
            }
        } catch (Tymon\JWTAuth\Exceptions\JWTException $e) {
            return response()->json(['error' => 'could_not_create_token'], 500);
        }

        return response()->json(compact('token'));
    }

    public function register(Request $request)
    {
        $user = JWTAuth::parseToken()->authenticate();

        // If the token is invalid
        if (!$user->isAdmin()) {
            return response()->json(['error' => 'niet geautoriseerd'], 401);
        }

        $user = User::create([
            'name'      => $request->name,
            'email'     => $request->email,
            'password'  => bcrypt($request->password),
        ]);

        return response()->json(['success' => 'gebruiker succesvol aangemaakt'], 200);
    }

    public function userInfo()
    {
        $user = JWTAuth::parseToken()->authenticate();

        // If the token is invalid
        if (! $user) {
            return response()->json(['invalid user'], 401);
        }

        return response()->json([
            'id'    => $user->id,
            'name'  => $user->name,
            'email' => $user->email,
            'role'  => $user->role
        ]);
    }
}

2 个答案:

答案 0 :(得分:0)

您似乎正在尝试从应用程序中某个名为Type的列中检索数据,而这些数据并不存在。

答案 1 :(得分:-2)

您可能未选择字段名称&#34;键入&#34;从DB获取数据时。