initial commit

This commit is contained in:
TheOnlyMace
2026-05-17 13:26:14 +02:00
commit 75299b723d
176 changed files with 20327 additions and 0 deletions

58
app/Models/VmDevice.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class VmDevice extends Model
{
public const TYPE_DISK = 'disk';
public const TYPE_NETWORK = 'network';
public const TYPE_USB = 'usb';
public const TYPE_PCI = 'pci';
public static function types(): array
{
return [
self::TYPE_DISK => 'Zusätzliche Festplatte',
self::TYPE_NETWORK => 'Netzwerk-Interface',
self::TYPE_USB => 'USB-Gerät',
self::TYPE_PCI => 'PCI Passthrough',
];
}
public static function typesFor(?\App\Models\User $user = null): array
{
$types = self::types();
if ($user && ! $user->isAdmin()) {
return array_intersect_key($types, array_flip([self::TYPE_DISK, self::TYPE_NETWORK]));
}
return $types;
}
protected $fillable = [
'customer_id',
'type',
'slot',
'config',
'sort_order',
];
protected function casts(): array
{
return [
'config' => 'array',
'sort_order' => 'integer',
];
}
public function vm(): BelongsTo
{
return $this->belongsTo(Customer::class, 'customer_id');
}
}