diff --git a/README.md b/README.md index eba681c..741bb04 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,7 @@ coss-side-scripting disabled sail exec laravel.test php artisan migrate:refresh --seed ## ChatGPT -see ChatGPT folder \ No newline at end of file +see ChatGPT folder + +#### Challenges +Convention, due to given database. Could be easier \ No newline at end of file diff --git a/device-app/app/Http/Controllers/DeviceController.php b/device-app/app/Http/Controllers/DeviceController.php index d138133..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..b40be93 --- /dev/null +++ b/device-app/app/Http/Controllers/LocationTransactionController.php @@ -0,0 +1,51 @@ + $device]); + } + + 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('/'); + } + + 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 redirect('/'); + } + + 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..60198fa --- /dev/null +++ b/device-app/app/Http/Controllers/OwnerTransactionController.php @@ -0,0 +1,51 @@ + $device]); + } + + 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('/'); + } + + 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 redirect('/'); + } + + 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..0602f3b --- /dev/null +++ b/device-app/app/Http/Controllers/PurchasingInformationController.php @@ -0,0 +1,54 @@ +validate([ + 'price' => 'required', + 'timestamp_warranty_end' => 'required', + 'timestamp_purchase' => 'required', + 'cost_centre' => 'required', + ]); + + PurchasingInformation::create($formFields); + + return redirect('/'); + } + + public function edit(Device $device) + { + return view('purchasings.edit', ['purchasing' => $device->purchasing]); + } + + public function update(Device $device, Request $request) + { + $formFields = $request->validate([ + 'price' => 'required', + 'timestamp_warranty_end' => 'required', + 'timestamp_purchase' => 'required', + 'cost_centre' => 'required', + ]); + + $device->purchasing->update($formFields); + + return redirect('/'); + } + + public function destroy(PurchasingInformation $purchasing) + { + $purchasing->delete(); + return back(); + } +} diff --git a/device-app/app/Models/Device.php b/device-app/app/Models/Device.php index bb38700..a058e48 100644 --- a/device-app/app/Models/Device.php +++ b/device-app/app/Models/Device.php @@ -2,12 +2,24 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use App\Models\OwnerTransaction; +use App\Models\LocationTransaction; +use App\Models\PurchasingInformation; +use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; class Device extends Model { - use HasFactory; + use HasFactory, HasUuids; + + /** + * The table associated with the model. + * @var string + */ + protected $table = 'devices'; /** * The primary key associated with the devices table. @@ -20,8 +32,22 @@ class Device extends Model * * @var array */ - protected $fillable = ['device_id', 'title', 'device_type', 'description', 'accessories', 'rz_username_buyer', 'serial_number', 'image_url']; + protected $fillable = [/* 'device_id', */'title', 'device_type', 'description', 'accessories', 'rz_username_buyer', 'serial_number', 'image_url']; + //The data type of the auto-incrementing ID. + protected $keyType = 'string'; //Timestamps are disabled. public $timestamps = false; + + public function owners(): HasMany { + return $this->hasMany(OwnerTransaction::class, 'device_id', 'device_id'); + } + + public function locations(): HasMany { + return $this->hasMany(LocationTransaction::class, 'device_id', 'device_id'); + } + + public function purchasing(): HasOne { + return $this->hasOne(PurchasingInformation::class, 'device_id', 'device_id'); + } } \ No newline at end of file diff --git a/device-app/app/Models/LocationTransaction.php b/device-app/app/Models/LocationTransaction.php new file mode 100644 index 0000000..6b24231 --- /dev/null +++ b/device-app/app/Models/LocationTransaction.php @@ -0,0 +1,40 @@ + + */ + protected $fillable = ['location_transaction_id', 'room_code', 'timestamp_located_since', 'device_id']; + + public function device(): BelongsTo { + return $this->belongsTo(Device::class, 'device_id', 'device_id'); + } + + //Timestamps are disabled. + public $timestamps = false; +} \ No newline at end of file diff --git a/device-app/app/Models/OwnerTransaction.php b/device-app/app/Models/OwnerTransaction.php new file mode 100644 index 0000000..c78cdc1 --- /dev/null +++ b/device-app/app/Models/OwnerTransaction.php @@ -0,0 +1,40 @@ + + */ + protected $fillable = ['owner_transaction_id', 'rz_username', 'timestamp_owner_since', 'device_id']; + + public function device(): BelongsTo { + return $this->belongsTo(Device::class, 'device_id', 'device_id'); + } + + //Timestamps are disabled. + public $timestamps = false; +} diff --git a/device-app/app/Models/PurchasingInformation.php b/device-app/app/Models/PurchasingInformation.php new file mode 100644 index 0000000..0e23e01 --- /dev/null +++ b/device-app/app/Models/PurchasingInformation.php @@ -0,0 +1,39 @@ + + */ + protected $fillable = ['purchasing_information_id', 'price', 'timestamp_warranty_end', 'timestamp_purchase', 'cost_centre', 'seller', 'device_id']; + + public function device(): BelongsTo { + return $this->belongsTo(Device::class, 'device_id', 'device_id'); + } + + //Timestamps are disabled. + public $timestamps = false; +} diff --git a/device-app/app/Models/User.php b/device-app/app/Models/User.php index d191d05..e388ac9 100644 --- a/device-app/app/Models/User.php +++ b/device-app/app/Models/User.php @@ -12,6 +12,12 @@ class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; + /** + * The table associated with the model. + * @var string + */ + protected $table = 'users'; + /** * The primary key associated with the users table. * @var string @@ -31,6 +37,8 @@ class User extends Authenticatable 'hashed_password' ]; + //ID is not auto-incrementing. + public $incrementing = false; //Timestamps are disabled. public $timestamps = false; diff --git a/device-app/app/View/Components/DeviceDetail.php b/device-app/app/View/Components/DeviceDetail.php new file mode 100644 index 0000000..42e93ad --- /dev/null +++ b/device-app/app/View/Components/DeviceDetail.php @@ -0,0 +1,26 @@ + $this->faker->randomDigitNotNull(), + 'device_id' => $this->faker->uuid(), 'title' => $this->faker->word(), 'device_type' => $this->faker->domainWord(), 'description' => $this->faker->sentence(), diff --git a/device-app/database/factories/LocationTransactionFactory.php b/device-app/database/factories/LocationTransactionFactory.php new file mode 100644 index 0000000..4883ffc --- /dev/null +++ b/device-app/database/factories/LocationTransactionFactory.php @@ -0,0 +1,24 @@ + + */ +class LocationTransactionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'room_code' => $this->faker->buildingNumber(), + 'timestamp_located_since' => $this->faker->unixTime() + ]; + } +} diff --git a/device-app/database/factories/OwnerTransactionFactory.php b/device-app/database/factories/OwnerTransactionFactory.php new file mode 100644 index 0000000..007ca82 --- /dev/null +++ b/device-app/database/factories/OwnerTransactionFactory.php @@ -0,0 +1,24 @@ + + */ +class OwnerTransactionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'rz_username' => $this->faker->name(), + 'timestamp_owner_since' => $this->faker->unixTime() + ]; + } +} diff --git a/device-app/database/factories/PurchasingInformationFactory.php b/device-app/database/factories/PurchasingInformationFactory.php new file mode 100644 index 0000000..5650060 --- /dev/null +++ b/device-app/database/factories/PurchasingInformationFactory.php @@ -0,0 +1,26 @@ + + */ +class PurchasingInformationFactory extends Factory +{ + /** + * Define the model's default state. + * @return array + */ + public function definition(): array + { + return [ + 'price' => $this->faker->word(), + 'timestamp_warranty_end' => $this->faker->unixTime(), + 'timestamp_purchase' => $this->faker->unixTime(), + 'cost_centre' => $this->faker->numberBetween(1000000000, 9999999999), + 'seller' => $this->faker->company() + ]; + } +} diff --git a/device-app/database/migrations/2023_03_20_114220_create_devices_table.php b/device-app/database/migrations/2023_03_20_114220_create_devices_table.php index 0a25560..b34de7a 100644 --- a/device-app/database/migrations/2023_03_20_114220_create_devices_table.php +++ b/device-app/database/migrations/2023_03_20_114220_create_devices_table.php @@ -12,7 +12,7 @@ public function up(): void { Schema::create('devices', function (Blueprint $table) { - $table->string('device_id')->unique(); + $table->uuid('device_id')->primary(); $table->string('title'); $table->string('device_type'); $table->string('description')->nullable(); diff --git a/device-app/database/migrations/2023_03_20_114828_create_location_transactions_table.php b/device-app/database/migrations/2023_03_20_114828_create_location_transactions_table.php index 6428fc7..ef33993 100644 --- a/device-app/database/migrations/2023_03_20_114828_create_location_transactions_table.php +++ b/device-app/database/migrations/2023_03_20_114828_create_location_transactions_table.php @@ -12,10 +12,10 @@ public function up(): void { Schema::create('location_transactions', function (Blueprint $table) { - $table->string('location_transaction_id')->unique(); + $table->uuid('location_transaction_id')->primary(); $table->string('room_code'); $table->string('timestamp_located_since'); - $table->string('device_id'); + $table->foreignUUid('device_id')->references('device_id')->on('devices')->cascadeOnUpdate()->cascadeOnDelete(); }); } diff --git a/device-app/database/migrations/2023_03_20_114834_create_owner_transactions_table.php b/device-app/database/migrations/2023_03_20_114834_create_owner_transactions_table.php index fa46372..185545d 100644 --- a/device-app/database/migrations/2023_03_20_114834_create_owner_transactions_table.php +++ b/device-app/database/migrations/2023_03_20_114834_create_owner_transactions_table.php @@ -12,10 +12,10 @@ public function up(): void { Schema::create('owner_transactions', function (Blueprint $table) { - $table->string('owner_transaction_id')->unique(); + $table->uuid('owner_transaction_id')->primary(); $table->string('rz_username'); $table->string('timestamp_owner_since'); - $table->string('device_id'); + $table->foreignUuid('device_id')->references('device_id')->on('devices')->cascadeOnUpdate()->cascadeOnDelete(); }); } diff --git a/device-app/database/migrations/2023_03_20_114945_create_purchasing_information_table.php b/device-app/database/migrations/2023_03_20_114945_create_purchasing_information_table.php index b158973..5262a22 100644 --- a/device-app/database/migrations/2023_03_20_114945_create_purchasing_information_table.php +++ b/device-app/database/migrations/2023_03_20_114945_create_purchasing_information_table.php @@ -12,13 +12,13 @@ public function up(): void { Schema::create('purchasing_information', function (Blueprint $table) { - $table->string('purchasing_information_id')->unique(); + $table->uuid('purchasing_information_id')->primary(); $table->string('price'); $table->string('timestamp_warranty_end'); $table->string('timestamp_purchase'); $table->string('cost_centre'); $table->string('seller')->nullable(); - $table->string('device_id')->unique(); + $table->foreignUuid('device_id')->references('device_id')->on('devices')->cascadeOnUpdate()->cascadeOnDelete(); }); } diff --git a/device-app/database/seeders/DatabaseSeeder.php b/device-app/database/seeders/DatabaseSeeder.php index db15d0b..20ef442 100644 --- a/device-app/database/seeders/DatabaseSeeder.php +++ b/device-app/database/seeders/DatabaseSeeder.php @@ -7,6 +7,9 @@ use App\Models\Device; use App\Models\User; use Illuminate\Database\Seeder; +use App\Models\OwnerTransaction; +use App\Models\LocationTransaction; +use App\Models\PurchasingInformation; class DatabaseSeeder extends Seeder { @@ -22,10 +25,15 @@ public function run(): void // 'email' => 'test@example.com', // ]); - Device::factory(2)->create(); + //Device::factory()->has(PurchasingInformation::factory()->count(1))->create(); + + Device::factory()->count(10) + ->has(PurchasingInformation::factory()->count(1), 'purchasing') + ->has(LocationTransaction::factory()->count(3), 'locations') + ->has(OwnerTransaction::factory()->count(3), 'owners') + ->create(); User::create([ - 'rz_username' => 'admin', 'full_name' => 'Admin', 'organisation_unit' => '11111111', diff --git a/device-app/resources/views/components/device-card.blade.php b/device-app/resources/views/components/device-card.blade.php deleted file mode 100644 index dd691d8..0000000 --- a/device-app/resources/views/components/device-card.blade.php +++ /dev/null @@ -1,4 +0,0 @@ -@props(['device']) -
- {{ $device->title }} -
\ No newline at end of file diff --git a/device-app/resources/views/components/device-detail.blade.php b/device-app/resources/views/components/device-detail.blade.php new file mode 100644 index 0000000..7049f8f --- /dev/null +++ b/device-app/resources/views/components/device-detail.blade.php @@ -0,0 +1,35 @@ +@props(['device']) +
+

Device Detail

+
    + +
  • title: {{ $device['title'] }}
  • +
  • device_type: {{ $device['device_type'] }}
  • +
  • description: {{ $device['description'] }}
  • +
  • accessories: {{ $device['accessories'] }}
  • +
  • rz_username_buyer: {{ $device['rz_username_buyer'] }}
  • +
  • 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 +
diff --git a/device-app/resources/views/components/device-simple.blade.php b/device-app/resources/views/components/device-simple.blade.php new file mode 100644 index 0000000..9f1b171 --- /dev/null +++ b/device-app/resources/views/components/device-simple.blade.php @@ -0,0 +1,16 @@ +@props(['device']) +
+ {{ $device->title }} +
    + + +
  • device_type: {{ $device['device_type'] }}
  • +
  • description: {{ $device['description'] }}
  • +
  • accessories: {{ $device['accessories'] }}
  • +
  • rz_username_buyer: {{ $device['rz_username_buyer'] }}
  • +
  • serial_number: {{ $device['serial_number'] }}
  • +
  • image_url: {{ $device['image_url'] }}
  • +
  • room_code: {{ $device->locations->last()['room_code'] }}
  • +
  • rz_username: {{ $device->owners->last()['rz_username'] }}
  • +
+
\ 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 new file mode 100644 index 0000000..632a17e --- /dev/null +++ b/device-app/resources/views/components/location-transaction.blade.php @@ -0,0 +1,12 @@ +
+
    +
  • 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 new file mode 100644 index 0000000..7105dad --- /dev/null +++ b/device-app/resources/views/components/owner-transaction.blade.php @@ -0,0 +1,12 @@ +
+
    +
  • 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 new file mode 100644 index 0000000..6d532ec --- /dev/null +++ b/device-app/resources/views/components/purchasing-information.blade.php @@ -0,0 +1,14 @@ +
+ @php + $purchasing = $device->purchasing; + @endphp +

Purchasing Information

+
    +
  • price: {{ $purchasing->price }}
  • +
  • timestamp_warranty_end: {{ $purchasing->timestamp_warranty_end }}
  • +
  • timestamp_purchase: {{ $purchasing->timestamp_purchase }}
  • +
  • cost_centre: {{ $purchasing->cost_centre }}
  • +
  • seller: {{ $purchasing->seller }}
  • +
+ +
\ No newline at end of file diff --git a/device-app/resources/views/devices/create.blade.php b/device-app/resources/views/devices/create.blade.php index 308a16a..428d877 100644 --- a/device-app/resources/views/devices/create.blade.php +++ b/device-app/resources/views/devices/create.blade.php @@ -3,51 +3,51 @@ @section('content')
@csrf - + - @error('device_id') + @error('title')

{{$message}}

@enderror
- @error('device_id') + @error('device_type')

{{$message}}

@enderror
- @error('device_id') + @error('accessories')

{{$message}}

@enderror
- @error('device_id') + @error('rz_username_buyer')

{{$message}}

@enderror
- @error('device_id') + @error('serial_number')

{{$message}}

@enderror
- @error('device_id') + @error('image_url')

{{$message}}

@enderror
- @error('device_id') + @error('description')

{{$message}}

@enderror
diff --git a/device-app/resources/views/devices/edit.blade.php b/device-app/resources/views/devices/edit.blade.php index 073da5a..e258154 100644 --- a/device-app/resources/views/devices/edit.blade.php +++ b/device-app/resources/views/devices/edit.blade.php @@ -4,12 +4,12 @@ @method('PUT') @csrf - + @error('device_id') diff --git a/device-app/resources/views/devices/index.blade.php b/device-app/resources/views/devices/index.blade.php index cd6742f..dc001f8 100644 --- a/device-app/resources/views/devices/index.blade.php +++ b/device-app/resources/views/devices/index.blade.php @@ -5,7 +5,7 @@ @unless(count($devices) == 0)
    @foreach ($devices as $device) - + @endforeach
@else diff --git a/device-app/resources/views/devices/show.blade.php b/device-app/resources/views/devices/show.blade.php index e3958e2..3956c16 100644 --- a/device-app/resources/views/devices/show.blade.php +++ b/device-app/resources/views/devices/show.blade.php @@ -1,22 +1,5 @@ @extends('layout') @section('content') -

Device Detail

-
    -
  • {{ $device['device_id'] }}
  • -
  • {{ $device['title'] }}
  • -
  • {{ $device['device_type'] }}
  • -
  • {{ $device['description'] }}
  • -
  • {{ $device['accessories'] }}
  • -
  • {{ $device['rz_username_buyer'] }}
  • -
  • {{ $device['serial_number'] }}
  • -
  • {{ $device['image_url'] }}
  • -
- - - - @method('DELETE') - @csrf - -
+ @endsection 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 new file mode 100644 index 0000000..db0791c --- /dev/null +++ b/device-app/resources/views/purchasings/edit.blade.php @@ -0,0 +1,36 @@ +
+ @method('PUT') + @csrf + + + @error('price') +

{{ $message }}

+ @enderror +
+ + + @error('timestamp_warranty_end') +

{{ $message }}

+ @enderror +
+ + + @error('timestamp_purchase') +

{{ $message }}

+ @enderror +
+ + + @error('cost_centre') +

{{ $message }}

+ @enderror +
+ + + @error('seller') +

{{ $message }}

+ @enderror + +
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