2023-03-31 10:52:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-03-31 11:39:03 +02:00
|
|
|
use App\Models\Device;
|
2023-03-31 10:52:12 +02:00
|
|
|
use Illuminate\Http\Request;
|
2023-04-04 15:52:47 +02:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2023-03-31 10:52:12 +02:00
|
|
|
|
|
|
|
class PurchasingInformationController extends Controller
|
|
|
|
{
|
|
|
|
|
2023-03-31 11:39:03 +02:00
|
|
|
public function edit(Device $device)
|
2023-03-31 10:52:12 +02:00
|
|
|
{
|
2023-03-31 17:17:09 +02:00
|
|
|
$this->authorize('admin-only');
|
2023-03-31 11:39:03 +02:00
|
|
|
return view('purchasings.edit', ['purchasing' => $device->purchasing]);
|
2023-03-31 10:52:12 +02:00
|
|
|
}
|
|
|
|
|
2023-03-31 11:39:03 +02:00
|
|
|
public function update(Device $device, Request $request)
|
2023-03-31 10:52:12 +02:00
|
|
|
{
|
2023-03-31 17:17:09 +02:00
|
|
|
$this->authorize('admin-only');
|
2023-03-31 10:52:12 +02:00
|
|
|
$formFields = $request->validate([
|
|
|
|
'price' => 'required',
|
|
|
|
'timestamp_warranty_end' => 'required',
|
|
|
|
'timestamp_purchase' => 'required',
|
|
|
|
'cost_centre' => 'required',
|
|
|
|
]);
|
|
|
|
|
2023-03-31 11:39:03 +02:00
|
|
|
$device->purchasing->update($formFields);
|
2023-03-31 10:52:12 +02:00
|
|
|
|
2023-04-04 15:52:47 +02:00
|
|
|
Log::info('Purchasing Information updated successfully');
|
|
|
|
|
2023-03-31 11:39:03 +02:00
|
|
|
return redirect('/');
|
2023-03-31 10:52:12 +02:00
|
|
|
}
|
|
|
|
}
|