Exemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Sla_plan $sla
  * @return type Response
  */
 public function destroy($id, Sla_plan $sla)
 {
     try {
         /* Delete a perticular field from the database by delete() using Id */
         $slas = $sla->whereId($id)->first();
         /* Check whether function success or not */
         if ($slas->delete() == true) {
             /* redirect to Index page with Success Message */
             return redirect('sla')->with('success', 'SLA Plan Deleted Successfully');
         } else {
             /* redirect to Index page with Fails Message */
             return redirect('sla')->with('fails', 'SLA Plan can not Delete');
         }
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('sla')->with('fails', 'SLA Plan can not Delete');
     }
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Sla_plan $sla
  * @return type Response
  */
 public function destroy($id, Sla_plan $sla)
 {
     $default_sla = Ticket::where('id', '=', '1')->first();
     if ($default_sla->sla == $id) {
         return redirect('departments')->with('fails', 'You cannot delete default department');
     } else {
         $tickets = DB::table('tickets')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
         if ($tickets > 0) {
             if ($tickets > 1) {
                 $text_tickets = "Tickets";
             } else {
                 $text_tickets = "Ticket";
             }
             $ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default SLA</li>';
         } else {
             $ticket = "";
         }
         $dept = DB::table('department')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
         if ($dept > 0) {
             if ($dept > 1) {
                 $text_dept = "Emails";
             } else {
                 $text_dept = "Email";
             }
             $dept = '<li>Associated department have been moved to default SLA</li>';
         } else {
             $dept = "";
         }
         $topic = DB::table('help_topic')->where('sla_plan', '=', $id)->update(['sla_plan' => $default_sla->sla]);
         if ($topic > 0) {
             if ($topic > 1) {
                 $text_topic = "Emails";
             } else {
                 $text_topic = "Email";
             }
             $topic = '<li>Associated Help Topic have been moved to default SLA</li>';
         } else {
             $topic = "";
         }
         $message = $ticket . $dept . $topic;
         /* Delete a perticular field from the database by delete() using Id */
         $slas = $sla->whereId($id)->first();
         /* Check whether function success or not */
         try {
             $slas->delete();
             /* redirect to Index page with Success Message */
             return redirect('sla')->with('success', 'SLA Plan Deleted Successfully' . $message);
         } catch (Exception $e) {
             /* redirect to Index page with Fails Message */
             return redirect('sla')->with('fails', 'SLA Plan can not Delete' . '<li>' . $e->errorInfo[2] . '</li>');
         }
     }
 }