Laravel API身份验证问题

时间:2017-10-17 11:22:32

标签: api laravel-5

我有一个Laravel APi路线。我正在使用内置令牌系统的简单API身份验证。

我的API路线看起来像这样

Route::group(['middleware' => ['subdomain_setup','auth:api'],'prefix'=>'v1'], function () {    
        Route::get('getCoupons', 'Api\CouponAPI@getCoupons');   
});

当我访问此路线时,它说

Unknown column 'api_token' in 'where clause' (SQL: select * from `users` where `api_token` = 

但api_token在用户表中。我不知道为什么我会收到这个错误。

我的用户模型如下所示:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password'
    ];

    protected $guarded = ['id'];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token', 'api_token'
    ];



    public static function boot()
    {
        parent::boot();
        static::creating(function($user){
            $user->act_token=str_random(40);
        });
    }

    public function confirmEmail()
    {
        $this->verified = true;
        $this->act_token =  null;

        $this->save();
    }
}

0 个答案:

没有答案
相关问题