/** * Fermeture d'un ticket */ public function close($id) { $ticket = Supports::where('id', $id)->where('id_author', $this->auth->user()->id)->where('message', '1')->first(); if ($this->auth->user()->id == $ticket->id_author) { DB::table('supports')->where('id', $id)->update(array('etat' => 2)); return redirect(url('support/' . $id))->with('success', 'Le ticket à bien été fermer !'); } else { return redirect(url('/'))->with('danger', 'Interdiction de faire ça ! xD'); } }
public function support_show($id) { $user = $this->auth->user(); $ticket = DB::table('supports')->where('id', $id)->where('message', 1)->where('id_refunds', '0')->first(); $Allusers = DB::table('users')->get(); $responses = Supports::where('reply', 1)->where('associated', $ticket->id)->get(); return view('admin.supports.show', compact('ticket', 'user', 'Allusers', 'responses')); }
/** * Répondre à un ticket ouvert dans une demande de remboursement */ public function reply_refunds($id, Request $request) { $content = $request->get("content"); $this->validate($request, ['content' => 'required|min:2']); $ticket = Supports::where('id', $id)->where('id_author', $this->auth->user()->id)->where('message', '1')->first(); $last_reply = Supports::where('associated', $id)->where('reply', '1')->orderBy('id', 'desc')->first(); $sup = DB::table('supports')->where('id', $id)->first(); if ($last_reply) { if ($this->auth->user()->id == $ticket->id_author) { if ($last_reply->id_author == $ticket->id_author) { return redirect(url('remboursement/' . $sup->id_refunds))->with('error', 'Veuillez attendre la réponse d\'un admin !'); } else { $supports = new Supports(); $supports->id_author = $this->auth->user()->id; $supports->reply = 1; $supports->associated = $id; $supports->content = $content; $supports->save(); DB::table('supports')->where('id', $id)->update(array('etat' => 1)); } return redirect(url('remboursement/' . $sup->id_refunds))->with('success', 'La réponse à bien été envoyer !'); } else { abort(403, 'Unauthorized action.'); } } else { $supports = new Supports(); $supports->id_author = $this->auth->user()->id; $supports->reply = 1; $supports->associated = $id; $supports->content = $content; $supports->save(); DB::table('supports')->where('id', $id)->update(array('etat' => 1)); return redirect(url('remboursement/' . $sup->id_refunds))->with('success', 'La réponse à bien été envoyer !'); } }