下記のイメージでしょうか?(isAdmin
に固定で1を設定しています。ここを適宜、帰れば良いのでは?)
php
1<?php
2
3use Faker\Generator as Faker;
4
5/*
6|--------------------------------------------------------------------------
7| Model Factories
8|--------------------------------------------------------------------------
9|
10| This directory should contain each of the model factory definitions for
11| your application. Factories provide a convenient way to generate new
12| model instances for testing / seeding your application's database.
13|
14*/
15
16$factory->define(\App\Models\M_User::class, function (Faker $faker) {
17 static $password;
18
19 return [
20 'name' => $faker->name,
21 'email' => $faker->unique()->safeEmail,
22 'password' => $password ?: $password = bcrypt('secret'),
23 'isAdmin'=>1,
24 'remember_token' => str_random(10),
25 ];
26});
上記の様な意味ではなく、自分で登録するデータを適当に変えたいの出ればSeeder
をいじる感じですかね?
php
1<?php
2
3use Illuminate\Database\Seeder;
4
5class UserTableSeeder extends Seeder
6{
7 8 * Run the database seeds.
9 *
1011
12 public function run()
13 {
14 //isAdminフラグが0のユーザーを作成
15 factory(App\Models\M_User::class)->create(['isAdmin'=>0]);
16
17 //isAdminフラグが1のユーザーを作成
18 factory(App\Models\M_User::class)->create(['isAdmin'=>1]);
19 }
20}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/30 06:40 編集
2018/01/30 06:42