'required|string|max:255|unique:device_models,name', 'label' => 'required|string|max:255', 'description' => 'required|string', 'width' => 'required|integer|min:1', 'height' => 'required|integer|min:1', 'colors' => 'required|integer|min:1', 'bit_depth' => 'required|integer|min:1', 'scale_factor' => 'required|numeric|min:0.1', 'rotation' => 'required|integer', 'mime_type' => 'required|string|max:255', 'offset_x' => 'required|integer', 'offset_y' => 'required|integer', 'published_at' => 'nullable|date', ]; public function mount() { $this->deviceModels = DeviceModel::all(); return view('livewire.device-models.index'); } public function createDeviceModel(): void { $this->validate(); DeviceModel::create([ 'name' => $this->name, 'label' => $this->label, 'description' => $this->description, 'width' => $this->width, 'height' => $this->height, 'colors' => $this->colors, 'bit_depth' => $this->bit_depth, 'scale_factor' => $this->scale_factor, 'rotation' => $this->rotation, 'mime_type' => $this->mime_type, 'offset_x' => $this->offset_x, 'offset_y' => $this->offset_y, 'published_at' => $this->published_at, ]); $this->reset(['name', 'label', 'description', 'width', 'height', 'colors', 'bit_depth', 'scale_factor', 'rotation', 'mime_type', 'offset_x', 'offset_y', 'published_at']); \Flux::modal('create-device-model')->close(); $this->deviceModels = DeviceModel::all(); session()->flash('message', 'Device model created successfully.'); } public $editingDeviceModelId; public function editDeviceModel(DeviceModel $deviceModel): void { $this->editingDeviceModelId = $deviceModel->id; $this->name = $deviceModel->name; $this->label = $deviceModel->label; $this->description = $deviceModel->description; $this->width = $deviceModel->width; $this->height = $deviceModel->height; $this->colors = $deviceModel->colors; $this->bit_depth = $deviceModel->bit_depth; $this->scale_factor = $deviceModel->scale_factor; $this->rotation = $deviceModel->rotation; $this->mime_type = $deviceModel->mime_type; $this->offset_x = $deviceModel->offset_x; $this->offset_y = $deviceModel->offset_y; $this->published_at = $deviceModel->published_at?->format('Y-m-d\TH:i'); } public function updateDeviceModel(): void { $deviceModel = DeviceModel::findOrFail($this->editingDeviceModelId); $this->validate([ 'name' => 'required|string|max:255|unique:device_models,name,' . $deviceModel->id, 'label' => 'required|string|max:255', 'description' => 'required|string', 'width' => 'required|integer|min:1', 'height' => 'required|integer|min:1', 'colors' => 'required|integer|min:1', 'bit_depth' => 'required|integer|min:1', 'scale_factor' => 'required|numeric|min:0.1', 'rotation' => 'required|integer', 'mime_type' => 'required|string|max:255', 'offset_x' => 'required|integer', 'offset_y' => 'required|integer', 'published_at' => 'nullable|date', ]); $deviceModel->update([ 'name' => $this->name, 'label' => $this->label, 'description' => $this->description, 'width' => $this->width, 'height' => $this->height, 'colors' => $this->colors, 'bit_depth' => $this->bit_depth, 'scale_factor' => $this->scale_factor, 'rotation' => $this->rotation, 'mime_type' => $this->mime_type, 'offset_x' => $this->offset_x, 'offset_y' => $this->offset_y, 'published_at' => $this->published_at, ]); $this->reset(['name', 'label', 'description', 'width', 'height', 'colors', 'bit_depth', 'scale_factor', 'rotation', 'mime_type', 'offset_x', 'offset_y', 'published_at', 'editingDeviceModelId']); \Flux::modal('edit-device-model-' . $deviceModel->id)->close(); $this->deviceModels = DeviceModel::all(); session()->flash('message', 'Device model updated successfully.'); } public function deleteDeviceModel(DeviceModel $deviceModel): void { $deviceModel->delete(); $this->deviceModels = DeviceModel::all(); session()->flash('message', 'Device model deleted successfully.'); } } ?>

Device Models

{{-- --}} {{-- Add Device Model--}} {{-- --}}
@if (session()->has('message'))
@endif
Add Device Model
Create Device Model
@foreach ($deviceModels as $deviceModel)
Edit Device Model
image/png image/bmp
Update Device Model
@endforeach @foreach ($deviceModels as $deviceModel) @endforeach
Description
Width
Height
Bit Depth
Actions
{{ $deviceModel->label }}
{{ Str::limit($deviceModel->name, 50) }}
{{ $deviceModel->width }} {{ $deviceModel->height }} {{ $deviceModel->bit_depth }}