database seed and some basic frontend

This commit is contained in:
TimmensOne 2023-03-23 21:50:31 +01:00
parent ad30a02a52
commit 0d22d49119
8 changed files with 106 additions and 13 deletions

View File

@ -20,4 +20,7 @@ The goal of this project is to develop a web application which manages the devic
propably MIT propably MIT
## Releasedate ## Releasedate
31.03.2023 latest: 15.04.2023
## About
Laravel is a full feature framework

View File

@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Device extends Model
{
public $timestamps = false;
use HasFactory;
}

View File

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Device>
*/
class DeviceFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
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'
];
}
}

View File

@ -2,6 +2,7 @@
namespace Database\Factories; namespace Database\Factories;
use Faker\Core\Number;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -18,11 +19,11 @@ class UserFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'name' => fake()->name(), 'rz_username' => 'admin',
'email' => fake()->unique()->safeEmail(), 'full_name' => 'Admin',
'email_verified_at' => now(), 'organisation_unit' => 11111111,
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'has_admin_privileges' => true,
'remember_token' => Str::random(10), 'hashed_password' => 'vollgeheim', // password
]; ];
} }

View File

@ -3,6 +3,9 @@
namespace Database\Seeders; namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents; // use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\Device;
use App\Models\User;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
@ -18,5 +21,33 @@ public function run(): void
// 'name' => 'Test User', // 'name' => 'Test User',
// 'email' => 'test@example.com', // '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'
// ]
//]);
} }
} }

View File

@ -1 +1,9 @@
<h1>Device DEtail</h1> <h1>Device Detail</h1>
<h2>{{ $device['device_id'] }}</h2>
<h2>{{ $device['title'] }}</h2>
<h2>{{ $device['device_type'] }}</h2>
<h2>{{ $device['description'] }}</h2>
<h2>{{ $device['accessories'] }}</h2>
<h2>{{ $device['rz_username_buyer'] }}</h2>
<h2>{{ $device['serial_number'] }}</h2>
<h2>{{ $device['image_url'] }}</h2>

View File

@ -1,8 +1,10 @@
<h1>Device List</h1> <h1>Device List</h1>
@unless(count($devices) == 0) @unless(count($devices) == 0)
@foreach ($devices as $device) @foreach ($devices as $device)
<h2>
<a href="/devices/{{ $device['device_id'] }}">{{$device['title']}}</<a>
</h2>
@endforeach @endforeach
@else @else
<p>No devices</p> <p>No devices</p>
@endunless @endunless

View File

@ -1,7 +1,7 @@
<?php <?php
use GuzzleHttp\Psr7\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Models\Device;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -19,9 +19,15 @@
}); });
Route::get('/devices', function () { Route::get('/devices', function () {
return view('deviceList'); //return view('deviceList');
return view('deviceList', [
//'devices' => Device::all()
'devices' => Device::all()
]);
}); });
Route::get('/devices/{id}', function ($id) { Route::get('/devices/{id}', function ($id) {
return view('deviceDetail'); return view('deviceDetail', [
'device' => Device::find($id)
]);
}); });