无法获取api令牌字段以填写Laravel 5.8

无法获取api令牌字段以填写Laravel 5.8,laravel,Laravel,我正在尝试使用Laravel5.8完成api注册系统。每次运行注册时,api_令牌字段都保持为空。我很确定我已经正确地遵循了说明,但我仍然遇到了错误 这就是我创建的迁移 <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class UpdateUsersTable exte

我正在尝试使用Laravel5.8完成api注册系统。每次运行注册时,api_令牌字段都保持为空。我很确定我已经正确地遵循了说明,但我仍然遇到了错误

这就是我创建的迁移

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class UpdateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //

        Schema::table('users', function ($table) {
    $table->string('api_token', 80)->after('password')
                        ->unique()
                        ->nullable()
                        ->default(null);
});

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}

这几乎就像“api_令牌”字段在该过程中被完全忽略一样。在此过程中,所有其他字段都已完成。

首先让我看看:您是否在您的用户模型的用户$filleble数组中添加了'api\u token'

/**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
            'api_token' => Str::random(60),
        ]);
    }