本文整理汇总了PHP中app\modules\user\models\User::where方法的典型用法代码示例。如果您正苦于以下问题:PHP User::where方法的具体用法?PHP User::where怎么用?PHP User::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\modules\user\models\User
的用法示例。
在下文中一共展示了User::where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::where('email', '=', 'test@test.com')->delete();
$user = factory(User::class)->create(['email' => 'test@test.com']);
Password::where('user_id', '=', $user->id)->delete();
$password = factory(Password::class)->create(['user_id' => $user->id, 'password' => Hash::make(str_random(15))]);
}
示例2: function
});
$factory->define(Password::class, function (Faker\Generator $faker) {
return ['password' => Hash::make('12345678')];
});
$factory->define(UserDetail::class, function (Faker\Generator $faker) {
$array = ['firstName' => $faker->firstName, 'lastName' => $faker->lastName, 'contactNumber' => $faker->phoneNumber];
if (random_int(0, 1) === 0) {
$array['emergencyContact'] = $faker->phoneNumber;
}
return $array;
});
$factory->define(UserRelationship::class, function (Faker\Generator $faker) {
return ['parent_user_id' => $faker->randomElement(User::all()->all())->id];
});
$factory->define(Message::class, function (Faker\Generator $faker) {
$array = ['from_user_id' => $from_user_id = $faker->randomElement(User::all()->all())->id, 'to_user_id' => $faker->randomElement(User::where('id', '!=', $from_user_id)->get()->all())->id, 'subject' => $faker->sentence, 'content' => $faker->sentences(random_int(3, 100), true), 'media_ids' => []];
if (Address::all()->count() > 0) {
for ($i = 0; $i < random_int(1, 10); $i++) {
$array['media_ids'][] = $faker->randomElement(Media::all()->all())->id;
}
}
$array['media_ids'] = json_encode($array['media_ids']);
return $array;
});
$factory->define(Brand::class, function (Faker\Generator $faker) {
return ['address_id' => $faker->randomElement(Address::all()->all())->id, 'settings' => json_encode([])];
});
$factory->define(Address::class, function (Faker\Generator $faker) {
return ['street' => $faker->streetAddress, 'suburb' => $faker->city, 'state' => $faker->city, 'country' => $faker->country, 'postcode' => $faker->postcode];
});
$factory->define(Media::class, function (Faker\Generator $faker) {