當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::where方法代碼示例

本文整理匯總了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))]);
 }
開發者ID:larryu,項目名稱:properta,代碼行數:12,代碼來源:DatabaseSeeder.php

示例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) {
開發者ID:larryu,項目名稱:properta,代碼行數:31,代碼來源:ModelFactory.php


注:本文中的app\modules\user\models\User::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。