2020-04-04 12:26:39 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Eloquent;
|
|
|
|
|
2020-04-09 22:35:38 -07:00
|
|
|
use Carbon\Carbon;
|
2020-04-04 12:26:39 -07:00
|
|
|
use Pterodactyl\Models\Backup;
|
|
|
|
|
|
|
|
class BackupRepository extends EloquentRepository
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return Backup::class;
|
|
|
|
}
|
2020-04-09 22:35:38 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if too many backups have been generated by the server.
|
|
|
|
*
|
|
|
|
* @param int $server
|
2020-12-27 16:41:53 -08:00
|
|
|
* @param int $seconds
|
2020-04-09 22:35:38 -07:00
|
|
|
* @return \Pterodactyl\Models\Backup[]|\Illuminate\Support\Collection
|
|
|
|
*/
|
2020-12-27 16:41:53 -08:00
|
|
|
public function getBackupsGeneratedDuringTimespan(int $server, int $seconds = 600)
|
2020-04-09 22:35:38 -07:00
|
|
|
{
|
|
|
|
return $this->getBuilder()
|
|
|
|
->withTrashed()
|
|
|
|
->where('server_id', $server)
|
2020-08-20 21:07:53 -07:00
|
|
|
->where('is_successful', true)
|
2020-12-27 16:41:53 -08:00
|
|
|
->where('created_at', '>=', Carbon::now()->subSeconds($seconds)->toDateTimeString())
|
2020-04-09 22:35:38 -07:00
|
|
|
->get()
|
|
|
|
->toBase();
|
|
|
|
}
|
2020-04-04 12:26:39 -07:00
|
|
|
}
|