0
0

More than 3 years have passed since last update.

【Laravel】seedデータの作り方

Posted at

<?php

use Illuminate\Database\Seeder;
use App\Models\User;

class UserTableSeeder extends Seeder
{
  /**
   * Run the database seeds.
   *
   * @return void
   */
  public function run()
  {
    factory(User::class, 5)->create();
    User::create([
      'id' => '100',
      'name' => '田中太郎',
      'name_kana' => 'タナカタロウ',
      'email' => 'test@rikai.technology',
      'tel' => '1234567890',
      'password' => bcrypt('password'),
    ]);
  }
}

database/seeds/UserTableSeeder.phpにこのような記述で、ダミーのデータを投入することができる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0