public function addToHistory(Media $media, $requester_id = null) { $request = History::create(); $request->save(array('media_id' => $media->id, 'requester_id' => $requester_id, 'played_at' => (new \DateTime())->format('Y-m-d H:i:s'))); }
public static function isRecentlyPlayed($id, $canRequestDateTime) { //Check if the media file has been recently played return History::where('media_id = :id AND played_at > :maxTime', ['id' => $id, 'maxTime' => $canRequestDateTime])->count() == 0 ? false : true; }