user(); $torrent = Torrent::findOrFail($id); $thank = Thank::where('user_id', $user->id)->where('torrent_id', $torrent->id)->first(); if ($thank) { return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::error('You Have Already Thanked On This Torrent!', 'Whoops!', ['options'])); } $thank = new Thank(); $thank->user_id = $user->id; $thank->torrent_id = $torrent->id; $thank->save(); return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::success('Your Thank Was Successfully Applied!', 'Yay!', ['options'])); } }