예제 #1
0
 /**
  * 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 !');
     }
 }
예제 #2
0
 public function refunds_open($id, Request $request)
 {
     if ($this->auth->user()->rank == 1) {
         abort(403);
     }
     $this->validate($request, ['content' => 'required|min:5']);
     $content = $request->get("content");
     $title = 'Remboursement #' . $id;
     $refunds = DB::table('refunds')->where('id', $id)->first();
     $user = DB::table('users')->where('arma', $refunds->playerid)->first();
     $supports = new Supports();
     $supports->id_author = $user->id;
     $supports->message = 1;
     $supports->title = $title;
     $supports->content = $content;
     $supports->etat = 3;
     $supports->id_refunds = $id;
     $supports->admin_refunds = $this->auth->user()->id;
     $supports->save();
     return redirect(url('admin/remboursement/' . $id))->with('success', 'Un ticket à bien été ouvert.');
 }
예제 #3
0
 /**
  * Ouverture d'un ticket en DB
  */
 public function open(Request $request)
 {
     $this->validate($request, ['content' => 'required|min:2', 'title' => 'required|min:5']);
     $title = $request->get("title");
     $content = $request->get("content");
     $supports = new Supports();
     $supports->id_author = $this->auth->user()->id;
     $supports->message = 1;
     $supports->title = $title;
     $supports->content = $content;
     $supports->etat = 0;
     $supports->id_refunds = 0;
     $supports->save();
     return redirect(url('/support'))->with('success', 'Le ticket à bien été ouvert');
 }