mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 15:36:52 +01:00 
			
		
		
		
	This allows the UI to correctly show failed backups to the user and require them to manually delete those backups, rather than them mysteriously disappearing. We can also hook into this later to send a notification to the user when the backup fails.
		
			
				
	
	
		
			36 lines
		
	
	
		
			878 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			878 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Pterodactyl\Repositories\Eloquent;
 | 
						|
 | 
						|
use Carbon\Carbon;
 | 
						|
use Pterodactyl\Models\Backup;
 | 
						|
 | 
						|
class BackupRepository extends EloquentRepository
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function model()
 | 
						|
    {
 | 
						|
        return Backup::class;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Determines if too many backups have been generated by the server.
 | 
						|
     *
 | 
						|
     * @param int $server
 | 
						|
     * @param int $minutes
 | 
						|
     * @return \Pterodactyl\Models\Backup[]|\Illuminate\Support\Collection
 | 
						|
     */
 | 
						|
    public function getBackupsGeneratedDuringTimespan(int $server, int $minutes = 10)
 | 
						|
    {
 | 
						|
        return $this->getBuilder()
 | 
						|
            ->withTrashed()
 | 
						|
            ->where('server_id', $server)
 | 
						|
            ->where('is_successful', true)
 | 
						|
            ->where('created_at', '>=', Carbon::now()->subMinutes($minutes)->toDateTimeString())
 | 
						|
            ->get()
 | 
						|
            ->toBase();
 | 
						|
    }
 | 
						|
}
 |