当前位置: 首页>>代码示例>>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;未经允许,请勿转载。