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

Location Transactions

- + @foreach ($locationTransactions as $location) @endforeach

Owner Transactions

- + @foreach ($ownerTransactins as $owner) @endforeach diff --git a/device-app/resources/views/locations/create.blade.php b/device-app/resources/views/locations/create.blade.php new file mode 100644 index 0000000..4ec2798 --- /dev/null +++ b/device-app/resources/views/locations/create.blade.php @@ -0,0 +1,17 @@ +
+ @csrf + + + @error('room_code') +

{{ $message }}

+ @enderror +
+ + + @error('timestamp_located_since') +

{{ $message }}

+ @enderror +
+ +
\ No newline at end of file diff --git a/device-app/resources/views/locations/edit.blade.php b/device-app/resources/views/locations/edit.blade.php new file mode 100644 index 0000000..670475e --- /dev/null +++ b/device-app/resources/views/locations/edit.blade.php @@ -0,0 +1,18 @@ +
+ @method('PUT') + @csrf + + + @error('room_code') +

{{ $message }}

+ @enderror +
+ + + @error('timestamp_located_since') +

{{ $message }}

+ @enderror +
+ +
\ No newline at end of file diff --git a/device-app/resources/views/owners/create.blade.php b/device-app/resources/views/owners/create.blade.php new file mode 100644 index 0000000..0983a38 --- /dev/null +++ b/device-app/resources/views/owners/create.blade.php @@ -0,0 +1,17 @@ +
+ @csrf + + + @error('rz_username') +

{{ $message }}

+ @enderror +
+ + + @error('timestamp_owner_since') +

{{ $message }}

+ @enderror +
+ +
\ No newline at end of file diff --git a/device-app/resources/views/owners/edit.blade.php b/device-app/resources/views/owners/edit.blade.php new file mode 100644 index 0000000..ea8da54 --- /dev/null +++ b/device-app/resources/views/owners/edit.blade.php @@ -0,0 +1,18 @@ +
+ @method('PUT') + @csrf + + + @error('rz_username') +

{{ $message }}

+ @enderror +
+ + + @error('timestamp_owner_since') +

{{ $message }}

+ @enderror +
+ +
\ No newline at end of file diff --git a/device-app/resources/views/purchasings/edit.blade.php b/device-app/resources/views/purchasings/edit.blade.php index 762a3af..db0791c 100644 --- a/device-app/resources/views/purchasings/edit.blade.php +++ b/device-app/resources/views/purchasings/edit.blade.php @@ -1,4 +1,3 @@ -

{{ $purchasing->price }}

@method('PUT') @csrf