fix edit purchasing information

This commit is contained in:
TimmensOne 2023-03-31 11:39:03 +02:00
parent 0e1de41203
commit d5770b8cb5
3 changed files with 50 additions and 12 deletions

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Device;
use App\Models\PurchasingInformation;
use Illuminate\Http\Request;
@ -26,12 +27,12 @@ public function store(Request $request)
return redirect('/');
}
public function edit(PurchasingInformation $purchasing)
public function edit(Device $device)
{
return view('purchasings.edit', ['purchasing' => $purchasing]);
return view('purchasings.edit', ['purchasing' => $device->purchasing]);
}
public function update(PurchasingInformation $purchasing, Request $request)
public function update(Device $device, Request $request)
{
$formFields = $request->validate([
'price' => 'required',
@ -40,9 +41,9 @@ public function update(PurchasingInformation $purchasing, Request $request)
'cost_centre' => 'required',
]);
$purchasing->update($formFields);
$device->purchasing->update($formFields);
return back();
return redirect('/');
}
public function destroy(PurchasingInformation $purchasing)

View File

@ -11,43 +11,43 @@
<br /-->
<label for="title">Title:</label>
<input type="text" id="title" name="title" value="{{old('title')}}" required>
@error('device_id')
@error('title')
<p>{{$message}}</p>
@enderror
<br />
<label for="device_type">device_type:</label>
<input type="text" id="device_type" name="device_type" value="{{old('device_type')}}" required>
@error('device_id')
@error('device_type')
<p>{{$message}}</p>
@enderror
<br />
<label for="accessories">accessories:</label>
<input type="text" id="accessories" name="accessories" value="{{old('accessories')}}">
@error('device_id')
@error('accessories')
<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="{{old('rz_username_buyer')}}" required>
@error('device_id')
@error('rz_username_buyer')
<p>{{$message}}</p>
@enderror
<br />
<label for="serial_number">serial_number:</label>
<input type="text" id="serial_number" name="serial_number" value="{{old('serial_number')}}" required>
@error('device_id')
@error('serial_number')
<p>{{$message}}</p>
@enderror
<br />
<label for="image_url">image_url:</label>
<input id="image_url" name="image_url" value="{{old('image_url')}}" required>
@error('device_id')
@error('image_url')
<p>{{$message}}</p>
@enderror
<br />
<label for="description">description:</label>
<textarea type="text" id="description" name="description">{{old('rz_username_buyer')}}</textarea>
@error('device_id')
@error('description')
<p>{{$message}}</p>
@enderror
<br />

View File

@ -0,0 +1,37 @@
<p>{{ $purchasing->price }}</p>
<form method="POST" action="/devices/{{ $purchasing->device->device_id }}/purchasing">
@method('PUT')
@csrf
<label for="price">price:</label>
<input type="text" id="price" name="price" value="{{$purchasing->price}}" required>
@error('price')
<p>{{ $message }}</p>
@enderror
<br />
<label for="timestamp_warranty_end">timestamp_warranty_end:</label>
<input type="text" id="timestamp_warranty_end" name="timestamp_warranty_end"
value="{{$purchasing->timestamp_warranty_end}}" required>
@error('timestamp_warranty_end')
<p>{{ $message }}</p>
@enderror
<br />
<label for="timestamp_purchase">timestamp_purchase:</label>
<input type="text" id="timestamp_purchase" name="timestamp_purchase"
value="{{$purchasing->timestamp_purchase}}" required>
@error('timestamp_purchase')
<p>{{ $message }}</p>
@enderror
<br />
<label for="cost_centre">cost_centre:</label>
<input type="text" id="cost_centre" name="cost_centre" value="{{$purchasing->cost_centre}}" required>
@error('cost_centre')
<p>{{ $message }}</p>
@enderror
<br />
<label for="seller">seller:</label>
<input type="text" id="seller" name="seller" value="{{$purchasing->seller}}">
@error('seller')
<p>{{ $message }}</p>
@enderror
<input type="submit" value="Submit">
</form>