Exemplo n.º 1
0
 public static function boot()
 {
     parent::boot();
     self::created(function ($usetting) {
         $users = User::all();
         foreach ($users as $user) {
             $user->settings()->attach($usetting);
         }
     });
 }
Exemplo n.º 2
0
 public static function boot()
 {
     parent::boot();
     User::created(function ($user) {
         // Setup default user settings for the new user
         $usettings = UserSetting::lists('default', 'id')->toArray();
         if ($usettings) {
             foreach ($usettings as $id => $value) {
                 $user_settings[$id] = ['value' => $value];
             }
             $user->settings()->sync($user_settings);
         }
     });
 }