diff --git a/device-app/app/Http/Controllers/LocationTransactionController.php b/device-app/app/Http/Controllers/LocationTransactionController.php index 4d23029..b40be93 100644 --- a/device-app/app/Http/Controllers/LocationTransactionController.php +++ b/device-app/app/Http/Controllers/LocationTransactionController.php @@ -2,23 +2,25 @@ namespace App\Http\Controllers; +use App\Models\Device; use Illuminate\Http\Request; use App\Models\LocationTransaction; class LocationTransactionController extends Controller { - public function create() + public function create(Device $device) { - return view('locations.create'); + return view('locations.create', ['device' => $device]); } - public function store(Request $request) + public function store(Device $device, Request $request) { $formFields = $request->validate([ 'room_code' => 'required', 'timestamp_located_since' => 'required' ]); + $formFields['device_id'] = $device->device_id; LocationTransaction::create($formFields); return redirect('/'); @@ -38,7 +40,7 @@ public function update(LocationTransaction $location, Request $request) $location->update($formFields); - return back(); + return redirect('/'); } public function destroy(LocationTransaction $location) diff --git a/device-app/app/Http/Controllers/OwnerTransactionController.php b/device-app/app/Http/Controllers/OwnerTransactionController.php index d660a21..60198fa 100644 --- a/device-app/app/Http/Controllers/OwnerTransactionController.php +++ b/device-app/app/Http/Controllers/OwnerTransactionController.php @@ -2,23 +2,25 @@ namespace App\Http\Controllers; +use App\Models\Device; use App\Models\OwnerTransaction; use Illuminate\Http\Request; class OwnerTransactionController extends Controller { - public function create() + public function create(Device $device) { - return view('owners.create'); + return view('owners.create', ['device' => $device]); } - public function store(Request $request) + public function store(Device $device, Request $request) { $formFields = $request->validate([ 'rz_username' => 'required', 'timestamp_owner_since' => 'required' ]); + $formFields['device_id'] = $device->device_id; OwnerTransaction::create($formFields); return redirect('/'); @@ -38,7 +40,7 @@ public function update(OwnerTransaction $owner, Request $request) $owner->update($formFields); - return back(); + return redirect('/'); } public function destroy(OwnerTransaction $owner) diff --git a/device-app/resources/views/components/device-detail.blade.php b/device-app/resources/views/components/device-detail.blade.php index c449aee..7049f8f 100644 --- a/device-app/resources/views/components/device-detail.blade.php +++ b/device-app/resources/views/components/device-detail.blade.php @@ -23,12 +23,12 @@ $ownerTransactins = $device->owners; @endphp
{{ $purchasing->price }}