// CONTROLLER FUNCTION
/**
* Thank A Uploader.
*
* @param $slug
* @param $id
*
* @return Illuminate\Http\RedirectResponse
*/
public function thank($slug, $id)
{
$user = auth()->user();
$post = Post::findOrFail($id);
$thank = Thank::where('user_id', '=', $user->id)->where('post_id', '=', $post_id->id)->first();
if ($thank) {
return redirect()->route('post', ['slug' => $post_id->slug, 'id' => $post_id->id])
->withErrors('You Have Already Thanked On This Post!');
}
$thank = new Thank();
$thank->user_id = $user->id;
$thank-> post_id = $post->id;
$thank->save();
//Notification
if ($user->id != $post->user_id) {
$torrent->notifyUploader('thank', $thank);
}
return redirect()->route('post', ['slug' => $post->slug, 'id' => $post->id])
->withSuccess('Your Thank Was Successfully Applied!');
}
// DEFAULT BLADE
@foreach (['warning', 'success', 'info'] as $key)
@if (Session::has($key))
<script nonce="{{ Bepsvpt\SecureHeaders\SecureHeaders::nonce() }}">
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000
});
Toast.fire({
type: '{{ $key }}',
title: '{{ Session::get($key) }}'
})
</script>
@endif
@endforeach