From 0d22d49119b6ffc62c149b45f45fde95b2e88a29 Mon Sep 17 00:00:00 2001 From: TimmensOne Date: Thu, 23 Mar 2023 21:50:31 +0100 Subject: [PATCH] database seed and some basic frontend --- README.md | 5 ++- device-app/app/Models/Device.php | 12 +++++++ .../database/factories/DeviceFactory.php | 30 ++++++++++++++++++ device-app/database/factories/UserFactory.php | 11 ++++--- .../database/seeders/DatabaseSeeder.php | 31 +++++++++++++++++++ .../resources/views/deviceDetail.blade.php | 10 +++++- .../resources/views/deviceList.blade.php | 8 +++-- device-app/routes/web.php | 12 +++++-- 8 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 device-app/app/Models/Device.php create mode 100644 device-app/database/factories/DeviceFactory.php diff --git a/README.md b/README.md index 0e0dc4e..7062429 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,7 @@ The goal of this project is to develop a web application which manages the devic propably MIT ## Releasedate -31.03.2023 \ No newline at end of file +latest: 15.04.2023 + +## About +Laravel is a full feature framework \ No newline at end of file diff --git a/device-app/app/Models/Device.php b/device-app/app/Models/Device.php new file mode 100644 index 0000000..dfaa44d --- /dev/null +++ b/device-app/app/Models/Device.php @@ -0,0 +1,12 @@ + + */ +class DeviceFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'device_id' => '1', + 'title' => 'Test Device One', + 'device_type' => 'type1', + 'description' => 'des', + 'accessories' => 'acc', + 'rz_username_buyer' => 'rzb', + 'serial_number' => '123', + 'image_url' => 'www.url.de' + ]; + } +} diff --git a/device-app/database/factories/UserFactory.php b/device-app/database/factories/UserFactory.php index a6ecc0a..a706390 100644 --- a/device-app/database/factories/UserFactory.php +++ b/device-app/database/factories/UserFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use Faker\Core\Number; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; @@ -18,11 +19,11 @@ class UserFactory extends Factory public function definition(): array { return [ - 'name' => fake()->name(), - 'email' => fake()->unique()->safeEmail(), - 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password - 'remember_token' => Str::random(10), + 'rz_username' => 'admin', + 'full_name' => 'Admin', + 'organisation_unit' => 11111111, + 'has_admin_privileges' => true, + 'hashed_password' => 'vollgeheim', // password ]; } diff --git a/device-app/database/seeders/DatabaseSeeder.php b/device-app/database/seeders/DatabaseSeeder.php index a9f4519..316e337 100644 --- a/device-app/database/seeders/DatabaseSeeder.php +++ b/device-app/database/seeders/DatabaseSeeder.php @@ -3,6 +3,9 @@ namespace Database\Seeders; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; + +use App\Models\Device; +use App\Models\User; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder @@ -18,5 +21,33 @@ public function run(): void // 'name' => 'Test User', // 'email' => 'test@example.com', // ]); + + Device::factory()->create([ + 'device_id' => '1', + 'title' => 'Test Device One', + 'device_type' => 'type1', + 'description' => 'des', + 'accessories' => 'acc', + 'rz_username_buyer' => 'rzb', + 'serial_number' => '123', + 'image_url' => 'www.url.de' + ]); + + //User::create([ + // [ + // 'rz_username' => 'admin', + // 'full_name' => 'Admin', + // 'organisation_unit' => '11111111', + // 'has_admin_privileges' => true, + // 'hashed_password' => 'vollgeheim' + // ], + // [ + // 'rz_username' => 'user', + // 'full_name' => 'User', + // 'organisation_unit' => '66666666', + // 'has_admin_privileges' => false, + // 'hashed_password' => 'test123' + // ] + //]); } } diff --git a/device-app/resources/views/deviceDetail.blade.php b/device-app/resources/views/deviceDetail.blade.php index 12655c9..5a380d8 100644 --- a/device-app/resources/views/deviceDetail.blade.php +++ b/device-app/resources/views/deviceDetail.blade.php @@ -1 +1,9 @@ -

Device DEtail

\ No newline at end of file +

Device Detail

+

{{ $device['device_id'] }}

+

{{ $device['title'] }}

+

{{ $device['device_type'] }}

+

{{ $device['description'] }}

+

{{ $device['accessories'] }}

+

{{ $device['rz_username_buyer'] }}

+

{{ $device['serial_number'] }}

+

{{ $device['image_url'] }}

diff --git a/device-app/resources/views/deviceList.blade.php b/device-app/resources/views/deviceList.blade.php index 798bf9a..a8e793c 100644 --- a/device-app/resources/views/deviceList.blade.php +++ b/device-app/resources/views/deviceList.blade.php @@ -1,8 +1,10 @@

Device List

@unless(count($devices) == 0) -@foreach($devices as $device) -@endforeach - + @foreach ($devices as $device) +

+ {{$device['title']}} +

+ @endforeach @else

No devices

@endunless diff --git a/device-app/routes/web.php b/device-app/routes/web.php index ec2f31d..752a9d0 100644 --- a/device-app/routes/web.php +++ b/device-app/routes/web.php @@ -1,7 +1,7 @@ Device::all() + 'devices' => Device::all() + ]); }); Route::get('/devices/{id}', function ($id) { - return view('deviceDetail'); + return view('deviceDetail', [ + 'device' => Device::find($id) + ]); });