本文整理汇总了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');
}
}
示例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']);
}
示例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);
}
示例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();
}
}
示例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('');
}
示例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();
}
示例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) {
}
}
}
示例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");
}
示例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();
}
示例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();
}
示例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;
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::truncate();
factory(User::class, 100)->create();
}
示例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']);
}
}
示例14: deleteAll
public function deleteAll()
{
return User::truncate();
}