abschlussprojekt-device-man.../device-app/app/Http/Controllers/PurchasingInformationController.php
2023-03-31 11:39:03 +02:00

55 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Device;
use App\Models\PurchasingInformation;
use Illuminate\Http\Request;
class PurchasingInformationController extends Controller
{
public function create()
{
return view('purchasings.create');
}
public function store(Request $request)
{
$formFields = $request->validate([
'price' => 'required',
'timestamp_warranty_end' => 'required',
'timestamp_purchase' => 'required',
'cost_centre' => 'required',
]);
PurchasingInformation::create($formFields);
return redirect('/');
}
public function edit(Device $device)
{
return view('purchasings.edit', ['purchasing' => $device->purchasing]);
}
public function update(Device $device, Request $request)
{
$formFields = $request->validate([
'price' => 'required',
'timestamp_warranty_end' => 'required',
'timestamp_purchase' => 'required',
'cost_centre' => 'required',
]);
$device->purchasing->update($formFields);
return redirect('/');
}
public function destroy(PurchasingInformation $purchasing)
{
$purchasing->delete();
return back();
}
}