Example #1
0
 public static function markFlag($id)
 {
     // Create the flag
     FlagList::create(['url' => $id, 'time' => Carbon::now()]);
     // Remove from queue/history queue
     $items = MusicQueue::where('url', $id)->get();
     // Shouldn't be in the queue more than once, but who knows
     foreach ($items as $item) {
         // Remove any copies of this video that might be in the queue
         $item->delete();
     }
     // Get all items with the same url in music_history
     $items = MusicHistory::where('url', $id)->get();
     // Remove all copies from music_history
     foreach ($items as $item) {
         $item->delete();
     }
 }
 public function report($id)
 {
     // Add to the flag list so an admin can approve or dissaprove it
     FlagList::markFlag($id);
     // If a video has been flagged more than 5 times, blacklist it
     $items = FlagList::where('url', $id)->get();
     $i = 0;
     // Conunt the number of times the video is on the flag list
     foreach ($items as $item) {
         $i += 1;
     }
     // Check if it has been flagged more than 10 times
     if ($i > 10) {
         // Blacklist the video
         BlackList::enroll($id, 'Flagged too many times.');
         Session::flash('info', 'The video has been blacklisted');
     }
     header('Location: /');
     exit;
 }