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); } }); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $user = $this->user->with('settings')->whereId($id)->first(); $settings = UserSetting::select('id', 'name', 'key', 'default')->orderBy('key', 'DESC')->get(); return view('berrier::admin.users.edit')->with(compact('user'))->with(compact('settings')); }