2017-09-10 04:55:21 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-09-10 04:55:21 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-09-10 04:55:21 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-13 04:45:19 +00:00
|
|
|
namespace Pterodactyl\Repositories\Eloquent;
|
2017-09-10 04:55:21 +00:00
|
|
|
|
2017-09-13 04:45:19 +00:00
|
|
|
use Pterodactyl\Models\Schedule;
|
|
|
|
use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface;
|
2017-09-10 04:55:21 +00:00
|
|
|
|
2017-09-13 04:45:19 +00:00
|
|
|
class ScheduleRepository extends EloquentRepository implements ScheduleRepositoryInterface
|
2017-09-10 04:55:21 +00:00
|
|
|
{
|
2017-09-13 04:45:19 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return Schedule::class;
|
|
|
|
}
|
2017-09-10 04:55:21 +00:00
|
|
|
|
2017-09-13 04:45:19 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getServerSchedules($server)
|
|
|
|
{
|
|
|
|
return $this->getBuilder()->withCount('tasks')->where('server_id', '=', $server)->get($this->getColumns());
|
2017-09-10 04:55:21 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 04:45:19 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getScheduleWithTasks($schedule)
|
2017-09-10 04:55:21 +00:00
|
|
|
{
|
2017-09-13 04:45:19 +00:00
|
|
|
return $this->getBuilder()->with('tasks')->find($schedule, $this->getColumns());
|
2017-09-10 04:55:21 +00:00
|
|
|
}
|
2017-09-17 04:10:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getSchedulesToProcess($timestamp)
|
|
|
|
{
|
|
|
|
return $this->getBuilder()->with('tasks')
|
|
|
|
->where('is_active', true)
|
|
|
|
->where('next_run_at', '<=', $timestamp)
|
|
|
|
->get($this->getColumns());
|
|
|
|
}
|
2017-09-10 04:55:21 +00:00
|
|
|
}
|