add device edit

This commit is contained in:
TimmensOne 2023-03-26 17:36:20 +02:00
parent f8fe2a1f33
commit f39a0f9443
4 changed files with 64 additions and 0 deletions

View File

@ -37,6 +37,10 @@ public function store(Request $request){
return redirect('/devices');
}
public function edit(Device $device) {
return view('devices.edit', ['device' => $device]);
}
public function show(Device $device)
{
return view('devices.show', [

View File

@ -0,0 +1,57 @@
@extends('layout')
@section('content')
<form method="POST" action="/devices/{{$device->device_id}}">
@csrf
@method('PUT')
<label for="device_id">device_id:</label>
<input type="text" id="device_id" name="device_id" value="{{$device->device_id}}" required>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="title">Title:</label>
<input type="text" id="title" name="title" value="{{$device->title}}" required>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="device_type">device_type:</label>
<input type="text" id="device_type" name="device_type" value="{{$device->device_type}}" required>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="accessories">accessories:</label>
<input type="text" id="accessories" name="accessories" value="{{$device->accessories}}">
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="rz_username_buyer">rz_username_buyer:</label>
<input type="text" id="rz_username_buyer" name="rz_username_buyer" value="{{$device->rz_username_buyer}}" required>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="serial_number">serial_number:</label>
<input type="text" id="serial_number" name="serial_number" value="{{$device->serial_number}}" required>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="image_url">image_url:</label>
<input id="image_url" name="image_url" value="{{$device->image_url}}" required>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<label for="description">description:</label>
<textarea type="text" id="description" name="description">{{$device->rz_username_buyer}}</textarea>
@error('device_id')
<p>{{$message}}</p>
@enderror
<br />
<input type="submit" value="Submit">
</form>
@endsection

View File

@ -12,4 +12,5 @@
<li>{{ $device['serial_number'] }}</li>
<li>{{ $device['image_url'] }}</li>
</ul>
<button><a href="{{$device->device_id}}/edit">Edit</a></button>
@endsection

View File

@ -29,6 +29,8 @@
Route::post('/devices', [DeviceController::class, 'store']);
// edit - show edit form
Route::get('devices/{device}/edit', [DeviceController::class, 'edit']);
// update - update device
// destroy - delete device
// show - show sigle device