Пример #1
0
 /**
  * render interface to edit a exists email
  *
  * @param $id
  * @param $person_id
  * @return \Illuminate\View\View
  */
 public function edit($person_id, $id)
 {
     $email = Email::where(['person_id' => $person_id, 'id' => $id])->first();
     if (count($email) != 1) {
         return view('errors.404');
     }
     return view('email.save', compact('email'));
 }
Пример #2
0
 /**
  * remove from database a email of a person
  *
  * @param $person_id
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($person_id, $id)
 {
     $email = $this->model->where(['person_id' => $person_id, 'id' => $id])->first();
     if (count($email) != 1) {
         return view('errors.404');
     }
     if ($email->delete()) {
         session(['success' => "o email [{$email->email}] foi removido com sucesso!"]);
     } else {
         session(['error' => "o email [{$email->email}] não foi removido!"]);
     }
     return redirect()->back();
 }
Пример #3
0
 public function destroy($id)
 {
     Email::destroy($id);
     return redirect()->route('agenda.index');
 }