So consider the following err:
[PDOException]
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "created_at" violates not-null constraint
DETAIL: Failing row contains (5, Sample Name xxx@gmail.com, xxxxxx, null, null, null).
This is the seeder:
<?php
use Illuminate\Database\Seeder;
class AdminUser extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert([
'name' => 'Sample Name',
'email' => 'xxxx@gmail.com',
'password' => 'xxxxxx',
]);
}
}
The user model:
class Users extends Model {
protected $table = 'users';
protected $timestamps = true;
protected $fillable = ['name', 'email', 'password', 'created_at', 'updated_at'];
}
Whats going on? The migration, default from laravel install:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
Did they miss something? Did I?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire