模型事件 生成的测试数据没有值

求教大神们, 使用artisan refresh --seed 生成测试数据 一直报错啊. 。调试半天也没结果..求教
at D:\laragon\www\xj\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {

664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|

Exception trace:

1 PDOException::("SQLSTATE[42S22]: Column not found: 1054 Unknown column 'emal_active' in 'field list'")
D:\laragon\www\xj\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452

2 PDO::prepare("insert into users (name, email, password, remember_token, email_token, emal_active, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?)")
D:\laragon\www\xj\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452

Please use the argument -v to see more details.

Process finished with exit code 1 at 15:38:46.
Execution time: 4,595 ms.

贴代码:

****
namespace App\ObServer;
use App\User;
class UserObServer\
{
  public function creating(User $user)\
     {  $user->email_token = str_random(10);\
      $user->emal_active = false;\
     }
 }
use Faker\Generator as Faker;
$factory->define(App\User::class, function (Faker $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
        'remember_token' => str_random(10),
    ];
});
 public function boot()
    {
        User::observe(UserObServer::class);
    }
附言 1  ·  5年前

上面为报错信息,下面为代码,..

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 2

file
不会看报错信息吗?就算英文不好,翻译也不会用吗

5年前 评论

@doobi 首先谢谢您,但是我感觉 不是这个错误造成的 因为表的字段已经创建上了 应为是下面一条报错引起的,,,
2 PDO::prepare("insert into users (name, email, password, remember_token, email_token, emal_active, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?)")

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!