本文整理匯總了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) {