where('prewarn', '=', 0) ->where('hitrun', '=', 0) ->where('immune', '=', 0) ->where('actual_downloaded', '>', 0) ->where('active', '=', 0) ->where('seedtime', '<=', config('hitrun.seedtime')) ->where('updated_at', '<', $current->copy()->subDays(config('hitrun.prewarn'))->toDateTimeString()) ->get(); foreach ($prewarn as $pre) { if (! $pre->user->group->is_immune) { if ($pre->actual_downloaded > ($pre->torrent->size * (config('hitrun.buffer') / 100))) { $exsist = Warning::withTrashed() ->where('torrent', '=', $pre->torrent->id) ->where('user_id', '=', $pre->user->id) ->first(); // Send Pre Warning PM If Actual Warning Doesnt Already Exsist if (! $exsist) { $timeleft = config('hitrun.grace') - config('hitrun.prewarn'); // Send Private Message $pm = new PrivateMessage(); $pm->sender_id = 1; $pm->receiver_id = $pre->user->id; $pm->subject = 'Hit and Run Warning Incoming'; $pm->message = 'You have received a automated [b]PRE-WARNING PM[/b] from the system because [b]you have been disconnected for '.config('hitrun.prewarn')." days on Torrent {$pre->torrent->name} and have not yet met the required seedtime rules set by ".config('other.title').". If you fail to seed it within {$timeleft} day(s) you will recieve a automated WARNING which will last ".config('hitrun.expire').' days![/b] [color=red][b] THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]'; $pm->save(); // Set History Prewarn $pre->prewarn = 1; $pre->save(); } } } } } } }