/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function getEdit($id, $c_id = null) { $data['global_prefix'] = Config::get('settings.global_prefix'); $data['domain'] = $c_id ? Domain::find($id) : Domain::find(Auth::user()->domain_id); $data['phone_number'] = $c_id ? PhoneNumber::find($c_id) : PhoneNumber::find($id); if (Request::segment(2) == "manage") { foreach (User::whereDomainId(Request::segment(3))->get() as $row) { $data['users'][$row['id']] = $row['username']; } } return View::make('phone_number.edit')->with('data', $data); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { $domain = Domain::find($id); $domain->delete(); $user = User::whereDomainId($id)->first(); if ($user) { $user->delete(); $phone_number = PhoneNumber::whereUserId($user->id)->first(); $phone_number->delete(); Event::fire('logger', array(array('phone_number_remove', array('id' => $phone_number->id, 'extension' => $phone_number->extension), 2))); } Event::fire('logger', array(array('domain_remove', array('id' => $id, 'domain_name' => $domain->domain), 2))); return Output::push(array('path' => 'domain', 'messages' => array('success' => _('Domain has been deleted')))); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = User::find($id); $profile = Profile::find($user->profile_id); $user->delete(); $profile->delete(); if ($user->domain_id == NULL) { $domain = Domain::whereUserId($id)->first(); if ($domain) { $domain->delete(); $subuser = User::whereDomainId($domain->id)->first(); $subuser->delete(); PhoneNumber::whereUserId($subuser->id)->delete(); } } Event::fire('logger', array(array('account_remove', array('id' => $id, 'username' => $user->username), 2))); $path = Request::segment(4) ? 'domain/users/' . Request::segment(4) : 'users'; $path = $user->domain_id ? $path : "managers"; return Output::push(array('path' => $path, 'messages' => array('success' => _('User has been deleted')))); }