2023-03-31 10:52:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-03-31 12:14:57 +02:00
|
|
|
use App\Models\Device;
|
2023-03-31 10:52:12 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Models\LocationTransaction;
|
|
|
|
|
|
|
|
class LocationTransactionController extends Controller
|
|
|
|
{
|
2023-03-31 12:14:57 +02:00
|
|
|
public function create(Device $device)
|
2023-03-31 10:52:12 +02:00
|
|
|
{
|
2023-03-31 12:14:57 +02:00
|
|
|
return view('locations.create', ['device' => $device]);
|
2023-03-31 10:52:12 +02:00
|
|
|
}
|
|
|
|
|
2023-03-31 12:14:57 +02:00
|
|
|
public function store(Device $device, Request $request)
|
2023-03-31 10:52:12 +02:00
|
|
|
{
|
|
|
|
$formFields = $request->validate([
|
|
|
|
'room_code' => 'required',
|
|
|
|
'timestamp_located_since' => 'required'
|
|
|
|
]);
|
|
|
|
|
2023-03-31 12:14:57 +02:00
|
|
|
$formFields['device_id'] = $device->device_id;
|
2023-03-31 10:52:12 +02:00
|
|
|
LocationTransaction::create($formFields);
|
|
|
|
|
|
|
|
return redirect('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function edit(LocationTransaction $location)
|
|
|
|
{
|
|
|
|
return view('locations.edit', ['location' => $location]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(LocationTransaction $location, Request $request)
|
|
|
|
{
|
|
|
|
$formFields = $request->validate([
|
|
|
|
'room_code' => 'required',
|
|
|
|
'timestamp_located_since' => 'required'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$location->update($formFields);
|
|
|
|
|
2023-03-31 12:14:57 +02:00
|
|
|
return redirect('/');
|
2023-03-31 10:52:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function destroy(LocationTransaction $location)
|
|
|
|
{
|
|
|
|
$location->delete();
|
|
|
|
return back();
|
|
|
|
}
|
|
|
|
}
|