user(); $torrent = Torrent::findOrFail($id); if ($user->id === $torrent->user_id) { return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id]) ->withErrors('You Cannot Thank Your Own Torrent!'); } $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]) ->withErrors('You Have Already Thanked On This Torrent!'); } $thank = new Thank(); $thank->user_id = $user->id; $thank->torrent_id = $torrent->id; $thank->save(); //Notification if ($user->id != $torrent->user_id) { $torrent->notifyUploader('thank', $thank); } return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id]) ->withSuccess('Your Thank Was Successfully Applied!'); } }