i am trying to insert values to admin seeder but it dosn't seed i don't know why i wrote everything correct and my error is General error: 1364 Field 'email' doesn't have a default value") and i don't want to make default value i just want to seed the table to fill informations here is my table admin
public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->timestamps();
});
}
and here is my model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Admin extends Authenticatable
{
use HasFactory;
protected $fillable = [
'name','email','password'
];
}
and here is my created AdminSedder.php
<?php
namespace Database\Seeders;
use App\Models\Admin;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class AdminSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('admins')->delete();
$infos = [
['name' => 'john'],
['email' => 'john@gm.com'],
['password' => Hash::make('12345678')],
];
foreach($infos as $info){
Admin::insert($info);
}
}
}
and my DatabaseSeeder
public function run()
{
$this->call(AdminSeeder::class);
}