diff --git a/device-app/app/Http/Controllers/DeviceController.php b/device-app/app/Http/Controllers/DeviceController.php index b4e3a0a..19a1a84 100644 --- a/device-app/app/Http/Controllers/DeviceController.php +++ b/device-app/app/Http/Controllers/DeviceController.php @@ -22,7 +22,6 @@ public function create(){ public function store(Request $request){ $formFields = $request->validate([ - //'device_id' => ['required', Rule::unique('devices', 'device_id')], 'title' => 'required', 'device_type' => 'required', 'description' => 'required', @@ -43,7 +42,6 @@ public function edit(Device $device) { public function update(Device $device, Request $request){ $formFields = $request->validate([ - //'device_id' => 'required', 'title' => 'required', 'device_type' => 'required', 'description' => 'required', diff --git a/device-app/app/Http/Controllers/LocationTransactionController.php b/device-app/app/Http/Controllers/LocationTransactionController.php new file mode 100644 index 0000000..4d23029 --- /dev/null +++ b/device-app/app/Http/Controllers/LocationTransactionController.php @@ -0,0 +1,49 @@ +validate([ + 'room_code' => 'required', + 'timestamp_located_since' => 'required' + ]); + + 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); + + return back(); + } + + public function destroy(LocationTransaction $location) + { + $location->delete(); + return back(); + } +} diff --git a/device-app/app/Http/Controllers/OwnerTransactionController.php b/device-app/app/Http/Controllers/OwnerTransactionController.php new file mode 100644 index 0000000..d660a21 --- /dev/null +++ b/device-app/app/Http/Controllers/OwnerTransactionController.php @@ -0,0 +1,49 @@ +validate([ + 'rz_username' => 'required', + 'timestamp_owner_since' => 'required' + ]); + + OwnerTransaction::create($formFields); + + return redirect('/'); + } + + public function edit(OwnerTransaction $owner) + { + return view('owners.edit', ['owner' => $owner]); + } + + public function update(OwnerTransaction $owner, Request $request) + { + $formFields = $request->validate([ + 'rz_username' => 'required', + 'timestamp_owner_since' => 'required' + ]); + + $owner->update($formFields); + + return back(); + } + + public function destroy(OwnerTransaction $owner) + { + $owner->delete(); + return back(); + } +} diff --git a/device-app/app/Http/Controllers/PurchasingInformationController.php b/device-app/app/Http/Controllers/PurchasingInformationController.php new file mode 100644 index 0000000..ead94c3 --- /dev/null +++ b/device-app/app/Http/Controllers/PurchasingInformationController.php @@ -0,0 +1,53 @@ +validate([ + 'price' => 'required', + 'timestamp_warranty_end' => 'required', + 'timestamp_purchase' => 'required', + 'cost_centre' => 'required', + ]); + + PurchasingInformation::create($formFields); + + return redirect('/'); + } + + public function edit(PurchasingInformation $purchasing) + { + return view('purchasings.edit', ['purchasing' => $purchasing]); + } + + public function update(PurchasingInformation $purchasing, Request $request) + { + $formFields = $request->validate([ + 'price' => 'required', + 'timestamp_warranty_end' => 'required', + 'timestamp_purchase' => 'required', + 'cost_centre' => 'required', + ]); + + $purchasing->update($formFields); + + return back(); + } + + public function destroy(PurchasingInformation $purchasing) + { + $purchasing->delete(); + return back(); + } +} diff --git a/device-app/resources/views/components/device-detail.blade.php b/device-app/resources/views/components/device-detail.blade.php index 750a92f..c449aee 100644 --- a/device-app/resources/views/components/device-detail.blade.php +++ b/device-app/resources/views/components/device-detail.blade.php @@ -11,17 +11,25 @@
  • serial_number: {{ $device['serial_number'] }}
  • image_url: {{ $device['image_url'] }}
  • + +
    + @method('DELETE') + @csrf + +
    @php $locationTransactions = $device->locations; $ownerTransactins = $device->owners; @endphp

    Location Transactions

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

    Owner Transactions

    + @foreach ($ownerTransactins as $owner) @endforeach - \ No newline at end of file + diff --git a/device-app/resources/views/components/location-transaction.blade.php b/device-app/resources/views/components/location-transaction.blade.php index 34abd4f..632a17e 100644 --- a/device-app/resources/views/components/location-transaction.blade.php +++ b/device-app/resources/views/components/location-transaction.blade.php @@ -3,4 +3,10 @@
  • room_code: {{ $location->room_code }}
  • timestamp_located_since: {{ $location->timestamp_located_since }}
  • + +
    + @method('DELETE') + @csrf + +
    \ No newline at end of file diff --git a/device-app/resources/views/components/owner-transaction.blade.php b/device-app/resources/views/components/owner-transaction.blade.php index 07b6452..7105dad 100644 --- a/device-app/resources/views/components/owner-transaction.blade.php +++ b/device-app/resources/views/components/owner-transaction.blade.php @@ -3,4 +3,10 @@
  • rz_username: {{ $owner->rz_username }}
  • timestamp_owner_since: {{ $owner->timestamp_owner_since }}
  • + +
    + @method('DELETE') + @csrf + +
    \ No newline at end of file diff --git a/device-app/resources/views/components/purchasing-information.blade.php b/device-app/resources/views/components/purchasing-information.blade.php index ac4d14c..6d532ec 100644 --- a/device-app/resources/views/components/purchasing-information.blade.php +++ b/device-app/resources/views/components/purchasing-information.blade.php @@ -10,4 +10,5 @@
  • cost_centre: {{ $purchasing->cost_centre }}
  • seller: {{ $purchasing->seller }}
  • + \ No newline at end of file diff --git a/device-app/resources/views/devices/show.blade.php b/device-app/resources/views/devices/show.blade.php index 72e9e29..3956c16 100644 --- a/device-app/resources/views/devices/show.blade.php +++ b/device-app/resources/views/devices/show.blade.php @@ -2,11 +2,4 @@ @section('content') - - -
    - @method('DELETE') - @csrf - -
    @endsection diff --git a/device-app/routes/web.php b/device-app/routes/web.php index 8908730..e88a952 100644 --- a/device-app/routes/web.php +++ b/device-app/routes/web.php @@ -1,6 +1,9 @@ middleware('auth'); // store - store new device Route::post('/devices', [DeviceController::class, 'store'])->middleware('auth'); + +// Device purchasing routes +//Route::get('/devices/{device}/purchasing/create', [PurchasingInformationController::class, 'create']); +//Route::post('/devices/{device}/purchasing', [PurchasingInformationController::class, 'store']); +Route::get('/devices/{device}/purchasing/edit', [PurchasingInformationController::class, 'edit']); +Route::put('/devices/{device}/purchasing', [PurchasingInformationController::class, 'update']); +//Route::delete('/devices/{device}/purchasing', [PurchasingInformationController::class, 'destroy']); + +// Device location routes +Route::get('/devices/{device}/locations/create', [LocationTransactionController::class, 'create']); +Route::post('/devices/{device}/locations', [LocationTransactionController::class, 'store']); +Route::get('/devices/locations/{location}/edit', [LocationTransactionController::class, 'edit']); +Route::put('/devices/locations/{location}', [LocationTransactionController::class, 'update']); +Route::delete('/devices/locations/{location}', [LocationTransactionController::class, 'destroy']); + +// Device owner routes +Route::get('/devices/{device}/owners/create', [OwnerTransactionController::class, 'create']); +Route::post('/devices/{device}/owners', [OwnerTransactionController::class, 'store']); +Route::get('/devices/owners/{owner}/edit', [OwnerTransactionController::class, 'edit']); +Route::put('/devices/owners/{owner}', [OwnerTransactionController::class, 'update']); +Route::delete('/devices/owners/{owner}', [OwnerTransactionController::class, 'destroy']); + +// // edit - show edit form Route::get('devices/{device}/edit', [DeviceController::class, 'edit'])->middleware('auth'); // update - update device @@ -34,6 +64,7 @@ // show - show sigle device Route::get('/devices/{device}', [DeviceController::class, 'show']); +//User routes // create - show register form Route::get('/register', [UserController::class, 'create']); // store - store new user @@ -43,4 +74,4 @@ // authenticate - log in user Route::post('/users/authenticate', [UserController::class, 'authenticate']); // logout - log out user -Route::post('/logout', [UserController::class, 'logout']); +Route::post('/logout', [UserController::class, 'logout']); \ No newline at end of file