This commit is contained in:
Saeed Vaziry
2025-05-21 21:05:13 +02:00
parent fe3317692b
commit a40c2828c2
20 changed files with 568 additions and 14 deletions

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Resources;
use App\Models\Backup;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin Backup */
class BackupResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'server_id' => $this->server_id,
'storage_id' => $this->storage_id,
'storage' => StorageProviderResource::make($this->storage),
'database_id' => $this->database_id,
'database' => DatabaseResource::make($this->database),
'type' => $this->type,
'keep_backups' => $this->keep_backups,
'interval' => $this->interval,
'files_count' => $this->files_count,
'status' => $this->status,
'last_file' => BackupFileResource::make($this->whenLoaded('lastFile')),
'status_color' => Backup::$statusColors[$this->status] ?? 'outline',
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}