public static function defaultSetting($user) { $settings = PrivacyHelper::defaultPrivacy(); $settings += array('gadget_container_0_sort' => 'about,friends', 'gadget_container_1_sort' => 'scheduler,newpost'); foreach ($settings as $key => $value) { $setting = new Setting(); $setting->key = $key; $setting->value = $value; $setting->created_by = $user->id; $setting->save(); } }
public function run() { $usersData = array(array('username' => 'yuyu', 'full_name' => 'Clicia Scarlet', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'is_active' => 1, 'bio' => 'Nothing to say', 'website' => 'http://google.com', 'location' => 'Hanoi', 'language' => 'English, Vietnamese, Japanese'), array('username' => 'abc', 'full_name' => 'Abc Xyz', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'is_active' => 1, 'bio' => null, 'website' => null, 'location' => null, 'language' => null), array('username' => 'huyvq', 'full_name' => 'Vu Quoc Huy', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'is_active' => 1, 'bio' => null, 'website' => 'http://cloma.clicia.me', 'location' => 'Vietnam', 'language' => 'English'), array('username' => 'quang', 'full_name' => 'Bui Van Quang', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'is_active' => 1, 'bio' => null, 'website' => 'http://cloma.com', 'location' => 'Earth', 'language' => 'Japanese')); $settingsData = array(); $settings = PrivacyHelper::defaultPrivacy() + array('gadget_container_0_sort' => 'about,friends', 'gadget_container_1_sort' => 'scheduler,newpost'); foreach ($settings as $key => $value) { foreach ($usersData as $id => $userData) { $settingsData[] = array('key' => $key, 'value' => $value, 'created_by' => $id + 1); } } DB::table('users')->truncate(); DB::table('settings')->truncate(); DB::table('users')->insert($usersData); DB::table('settings')->insert($settingsData); }