当前位置: 首页>>代码示例>>PHP>>正文


PHP User::truncate方法代码示例

本文整理汇总了PHP中app\models\User::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP User::truncate方法的具体用法?PHP User::truncate怎么用?PHP User::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::truncate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     Staff::truncate();
     Student::truncate();
     StudentNumber::truncate();
     StaffNumber::truncate();
     $user = ['first_name' => 'Jose Antonio', 'last_name' => 'Sinadinse', 'fullname' => '', 'password' => \Hash::make('password'), 'email' => 'toniobarros@hotmail.com', 'address' => 'Pretoria', 'cellnumber' => '000000000', 'user_type_id' => 1, 'state_id' => 1];
     if (StaffNumber::all()->count() == 0) {
         $stfnum = StaffNumber::create(["number" => 2000, "date" => date("Y-m-d")]);
     } else {
         $lateststfnum = StaffNumber::all()->last();
         $stfnum = StaffNumber::create(["number" => $lateststfnum->number + 1, "date" => date("Y-m-d")]);
     }
     $staff = Staff::create(['staff_number' => $stfnum->number]);
     $user = $staff->user()->create($user);
     $user->addPermission('admin');
     for ($i = 3; $i < 20; $i++) {
         $user = ['first_name' => 'Name' . $i, 'last_name' => 'Surname' . $i, 'fullname' => '', 'password' => \Hash::make('aleluia'), 'email' => 'josebarros' . $i . '@hotmail.com', 'address' => 'Pretoria', 'cellnumber' => '00000000' . $i, 'user_type_id' => 3, 'state_id' => 1];
         if (StudentNumber::all()->count() == 0) {
             $stdnum = StudentNumber::create(["number" => 200000000, "date" => date("Y-m-d")]);
         } else {
             $lateststdnum = StudentNumber::all()->last();
             $stdnum = StudentNumber::create(["number" => $lateststdnum->number + 1, "date" => date("Y-m-d")]);
         }
         $student = Student::create(['student_number' => $stdnum->number, "university_id" => 1, "faculty_id" => '', "department_id" => '', "course_id" => '']);
         $user = $student->user()->create($user);
         $user->addPermission('student');
     }
 }
开发者ID:joaonzangoII,项目名称:find_my_campuses_friend,代码行数:35,代码来源:DatabaseSeeder.php

示例2: seed

 public function seed()
 {
     User::truncate();
     User::create(['name' => 'Admin', 'email' => 'admin@mayden.co.uk', 'password' => bcrypt('password')]);
     User::create(['name' => 'User', 'email' => 'user@mayden.co.uk', 'password' => bcrypt('password')]);
     User::create(['name' => 'New', 'email' => 'new@mayden.co.uk', 'password' => bcrypt('password')]);
     Package::create(['name' => 'BriansDBMT', 'namespace' => 'TomButts-BriansDBMT-Migrate', 'version' => 'dev-master']);
 }
开发者ID:hannahtinkler,项目名称:too-tool-for-school,代码行数:8,代码来源:DatabaseSeeder.php

示例3: run

 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     User::truncate();
     $adminRole = Role::whereName('administrator')->first();
     $userRole = Role::whereName('user')->first();
     $user = User::create(array('first_name' => 'Suchay', 'last_name' => 'Janbandhu', 'email' => 'suchayj@easymanage.dev', 'password' => Hash::make('password'), 'confirmed' => 1));
     $user->assignRole($adminRole);
     $user = User::create(array('first_name' => 'Viplove', 'last_name' => 'Wahane', 'email' => 'viplovew@easymanage.dev', 'password' => Hash::make('password'), 'confirmed' => 1));
     $user->assignRole($userRole);
 }
开发者ID:suchayj,项目名称:easymanage,代码行数:11,代码来源:UserSeeder.php

示例4: run

 function run()
 {
     User::truncate();
     foreach (range(1, 30) as $n) {
         $User = new User();
         $User->id = $n;
         $User->email = 'user' . $n . '@test.com';
         $User->password = '123456';
         $User->save();
     }
 }
开发者ID:num8er,项目名称:techery_test,代码行数:11,代码来源:UsersSeed.php

示例5: run

 public function run()
 {
     User::truncate();
     // Random Password
     //$password = str_random(8);
     $password = 'nuwira';
     User::create(['username' => 'nuwira', 'name' => 'Nuwira', 'email' => 'hi@nuwira.com', 'password' => Hash::make($password), 'is_active' => 1]);
     $this->command->info('');
     $this->command->comment(' Username : nuwira');
     $this->command->comment(' Password : ' . $password);
     $this->command->info('');
 }
开发者ID:nuwira,项目名称:tunggorono,代码行数:12,代码来源:UserTableSeeder.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0');
     User::truncate();
     Role::truncate();
     Permission::truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1');
     Model::unguard();
     $this->call(UserTableSeeder::class);
     $this->call(RolesTableSeeder::class);
     $this->call(PermissionsTableSeeder::class);
     Model::reguard();
 }
开发者ID:viethung09,项目名称:trinity,代码行数:18,代码来源:DatabaseSeeder.php

示例7: run

 public function run()
 {
     User::truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         try {
             // Create the user
             $user = Sentry::createUser(array('first_name' => $faker->name, 'last_name' => $faker->name, 'email' => $faker->unique()->email, 'phone' => $faker->unique()->phoneNumber, 'image_url' => $faker->imageUrl($width = 640, $height = 480), 'password' => '123', 'activated' => true));
             // Find the group using the group id
             $adminGroup = Sentry::findGroupById($faker->randomElement(array(1, 2, 3)));
             // Assign the group to the user
             $user->addGroup($adminGroup);
         } catch (\Exception $e) {
         }
     }
 }
开发者ID:ShuvarthiDhar,项目名称:tobacco,代码行数:16,代码来源:UserTableSeeder.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET FOREIGN_KEY_CHECKS = 0");
     User::truncate();
     $fileName = '2016-02-24-users';
     $table_name = 'users';
     $fullFile = 'database/seeds/main/csv/' . $fileName . '.csv';
     $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE {$table_name} FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n'", addslashes($fullFile));
     DB::connection()->getPdo()->exec($query);
     // DB::connection('common')->statement("TRUNCATE user_has_roles");
     // $fileName = '2016-02-17-user-has-roles';
     // $fullFile = 'database/seeds/common/csv/'.$fileName.'.csv';
     // $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE common.user_has_roles FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n'", addslashes($fullFile));
     // DB::connection('common')->getpdo()->exec($query);
     DB::statement("SET FOREIGN_KEY_CHECKS = 1");
 }
开发者ID:bobby-drk,项目名称:working-title,代码行数:21,代码来源:01-UsersSeeder.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call('UserTableSeeder');
     User::truncate();
     App\Models\Article::truncate();
     // App\Models\Category::truncate();
     // factory(User::class, 47)->create()->each(function($u) {
     // $n = rand(1,30);
     // // dd($u);
     // $u->articles()->save(factory(App\Models\Article::class, $n)->make());
     // });
     $users = factory(App\Models\User::class, 13)->create()->each(function ($u) {
         $n = rand(1, 30);
         for ($i = 1; $i < $n; $i++) {
             $u->articles()->save(factory(App\Models\Article::class)->make());
         }
     });
     // factory(App\Models\Article::class, 54)->create();
     factory(App\Models\Category::class, 20)->create();
     // factory(App\Mo/usdels\Comment::class, 98)->create();
     // factory(App\Models\Notification::class, 12)->create();
     Model::reguard();
 }
开发者ID:kaiyulee,项目名称:express,代码行数:29,代码来源:DatabaseSeeder.php

示例10: run

 public function run()
 {
     User::truncate();
     factory(User::class)->create(['name' => 'Eruza MSP', 'email' => 'eruza.msp@gmail.com', 'password' => bcrypt('eruza@msp')]);
     factory(User::class, 0)->create();
 }
开发者ID:sontdhust,项目名称:eruza,代码行数:6,代码来源:UsersTableSeeder.php

示例11: clearDatabasesForScenario

 protected function clearDatabasesForScenario()
 {
     \App\Models\Block::truncate();
     \App\Models\Transaction::truncate();
     \App\Models\Notification::truncate();
     \App\Models\MonitoredAddress::truncate();
     \App\Models\PaymentAddress::truncate();
     \App\Models\Send::truncate();
     \App\Models\User::truncate();
     \App\Models\Account::truncate();
     \App\Models\APICall::truncate();
     \App\Models\LedgerEntry::truncate();
     return;
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:14,代码来源:ScenarioRunner.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     factory(User::class, 100)->create();
 }
开发者ID:gultaj,项目名称:react-tutorial-backend,代码行数:10,代码来源:UsersTableSeeder.php

示例13: migrate_user

 protected function migrate_user()
 {
     $old_collection = 'users';
     $new_collection = 'v2_users';
     $website = Website::first();
     // get old articles
     User::truncate();
     DB::connection('mysql')->table('works')->truncate();
     DB::connection('mongodb')->collection($old_collection)->chunk(1000, function ($data) use($new_collection, $website) {
         foreach ($data as $x) {
             $user = new User(['name' => isset($x['name']) ? $x['name'] : $x['username'], 'username' => $x['username'], 'email' => isset($x['email']) ? $x['email'] : '', 'password' => \Hash::make('123123')]);
             if ($user->save()) {
                 $user->works()->attach($website, ['start_at' => \Carbon\Carbon::now(), 'end_at' => null, 'role' => 'writer']);
             }
         }
     });
     $user = new User(['name' => "Erick Mo", 'username' => "erickmo", 'email' => "mo@thunderlab.id", 'password' => \Hash::make('123123')]);
     if ($user->save()) {
         $user->works()->attach($website, ['start_at' => \Carbon\Carbon::now(), 'end_at' => null, 'role' => 'super']);
     }
 }
开发者ID:ThunderID,项目名称:Halo,代码行数:21,代码来源:newHalo.php

示例14: deleteAll

 public function deleteAll()
 {
     return User::truncate();
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:4,代码来源:UserRepository.php


注:本文中的app\models\User::truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。