Scope a query to only include activities older than a timestamp

@param \Illuminate\Database\Eloquent\Builder
@param Carbon|int $time
@return \Illuminate\Database\Eloquent\Builder
557735
public function scopeOlderThan($query, $time)
    {
        if ( ! $time instanceof Carbon)
        {
            $time = Carbon::createFromTimestamp($time);
        }

        return $query->where('created_at', '<=', $time->toDateTimeString())->latest();
    }
161496
public static function get_fields_from_time($time) {
        $calendartype = \core_calendar\type_factory::get_calendar_instance();
        $wrongfields = $calendartype->timestamp_to_date_array($time);
        return array('day' => $wrongfields['mday'],
                'month' => $wrongfields['mon'], 'year' => $wrongfields['year'],
                'hour' => $wrongfields['hours'], 'minute' => $wrongfields['minutes']);
    }
1087525
public function setLastVisit($timestamp = 'now')
	{
		$timestamp = new Date($timestamp);

		$query = $this->getQuery()
			->update($this->getTableName())
			->set(array('lastvisitDate' => $timestamp->toSql()))
			->whereEquals('id', $this->get('id'));

		return $query->execute();
	}
130332
public function accessed($path, $time = null)
    {
        // If no time has been given, default to current time.
        $time = ($time === null) ? time() : $time;

        // Insert new cached item into meta data storage
        $query = $this->db->prepare('UPDATE metadata SET accessed = :accessed WHERE path = :path');
        $query->bindValue(':path',     $path);
        $query->bindValue(':accessed', $time);
        $query->execute();
    }
1222722
public function setLastLoginTime(\DateTime $time = null)
	{
		if (is_null($time)) {
			$time = new \DateTime();
		}
		$this->lastLoginTime = $time;
	}
989844
public function expiresAfter($time)
    {
        $this->expiration = new \DateTime();
        if (is_int($time)) {
            if ($time < 0) {
                $time = new \DateInterval('PT' . abs($time) . 'S');
                $time->invert = 1;
            } else {
                $time = new \DateInterval('PT' . $time . 'S');
            }
        }
        $this->expiration->add($time);
        $this->changed = true;
        return $this;
    }
1314268
public function back($time = 0)
    {
        $this->redirector->setTarget(Request::back());
        $this->redirector->setTime($time);

        return $this;
    }
1281946
public function revisionAtTimestamp($timestamp)
    {
        $revision = $this->revisions()
                         ->where('created_at', '<=', Carbon::parse($timestamp))
                         ->first();

        return $this->wrapRevision($revision);
    }
980197
public function timeStamp($timestamp = null) 
     {
        $ts = $timestamp ?: $this->getAttribute("timeStamp");
        if (is_integer($ts) || $ts instanceof TimeWindow) {
            return new TimeWindow(["timeStamp" => $ts]);
        }

        return new TimeWindow();
    }
105228
public function changeTime( Time $time )
      : DateTime
   {

      return $this->setTime( $time->getHour(), $time->getMinute(), $time->getSecond() );

   }
66309
public function gc( $time )
	{
		// if we don't have the last active key we cannot execute 
		// the garbage collection
		if ( !in_array( 'last_active', $this->index_fields ) )
		{
			return false;
		}
		
		\DB::delete( $this->table )
			->where( 'last_active', '<', time() - $time )
			->run( $this->database );
	}
544904
public final function expiresAfter($time)
   {
       $this->timeToLive = $time instanceof DateInterval
                         ? (new DateTime())->add($time)->getTimestamp()
                         - time()
                         : (int) $time;
       return $this;
   }
285354
public static function makeCsrfToken($time = null)
    {
        if (Session::getInstance()->has('__bow.csrf')) {
            return true;
        }

        if (is_int($time)) {
            static::$expirate_at = $time;
        }

        $token = static::make();

        Session::getInstance()->add('__bow.csrf', [
            'token' => $token,
            'expirate' => time() + static::$expirate_at,
            'field' => '<input type="hidden" name="_token" value="' . $token .'"/>'
        ]);

        Session::getInstance()->add('_token', $token);

        return true;
    }
1058484
public function setTime(DateTime $time = null)
    {
        $timestamp = $time ? $time->getTimestamp() : null;

        $this->session->put($this->timePersistenceKey, $timestamp);

        if ($time) {
            $this->setState(static::HISTORY);
        }

        return $this;
    }
1357661
public function getContextAt($time)
    {
        $l = $this->listLog(Logger::LOG_LEVEL_ALL, true, $time);
        if(!count($l) || $l[0]["time"] != $time){
            return null;
        }

        return $l[0]["context"];

    }
1012389
public static function sql($time = null): string
    {
        return self::factory($time)->format(self::SQL_FORMAT);
    }
585229
public function setTimestamp($timestamp = null)
    {
        $this->timestamp = $timestamp;
        if ($timestamp === null) {
            $this->timestamp = new Timestamp();
        }
        return $this;
    }