public function voted() { return $this->belongsToMany(Ticket::getClass(), 'ticket_votes')->withTimestamps(); }
public function popular() { $tickets = Ticket::all(); dd($tickets); }
/** * Submit the specified resource from storage. * * @param int $id * @return Response */ public function submit($id, Guard $auth) { $ticket = Ticket::findOrFail($id); //$data = auth()->user()->vote($ticket); currentUser()->vote($ticket); return redirect()->back(); }
public function findOrFail($id) { return Ticket::findOrFail($id); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function submit($id, Request $request, Guard $auth) { $this->validate($request, ['comment' => 'required|max:250', 'link' => 'url']); $comment = new TicketComment($request->only(['comment', 'link'])); $comment->user_id = $auth->id(); $ticket = Ticket::findOrFail($id); $ticket->comments()->save($comment); session()->flash('success', 'Tu comentario fue guardado exitosamente'); return redirect()->back(); }