模型事件 生成的测试数据没有值
求教大神们, 使用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);
}
上面为报错信息,下面为代码,..
推荐文章: