This commit is contained in:
Jonatan Rek 2024-08-06 16:20:45 +02:00
parent ecb255fc6a
commit 866eee5b16
5 changed files with 77 additions and 19 deletions

View File

@ -14,10 +14,16 @@ class DatabaseSeeder extends Seeder
public function run(): void
{
// User::factory(10)->create();
if (empty(User::where('email', 'test@example.co')->first())){
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
}
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
$this->call([
HostSeeder::class,
TaskSeeder::class,
]);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Database\Seeders;
use App\Models\Host;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class HostSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
foreach (['IT-PRG-DOCKER', 'IT-PRG-DOCKER02', 'CK-PRG-DOCKER01'] as $hostname) {
Host::create([
'hostname' => $hostname,
]);
}
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Seeders;
use App\Models\Task;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TaskSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
foreach (['Update Zabbixu', 'Instalace Aktualizací', 'Kontrola Logu'] as $name) {
Task::create([
'name' => $name,
'description' => $name,
]);
}
}
}

View File

@ -4,20 +4,23 @@
<h1>{{ __('Planned Maintenance') }}</h1>
</div>
<p>{!! $maintenance_history->maintenance->description !!}</p>
@foreach ($maintenance_history->historyHosts as $historyHost)
<div class="mb-3">
<div class="btn-toggle btn py-3 w-100 bg-primary text-start" style="--bs-bg-opacity: .2;" data-bs-toggle="collapse" data-bs-target="#collapse{{ $historyHost->id }}">
<b>{{ $historyHost->host->hostname }}</b>
</div>
<div class="collapse" id="collapse{{ $historyHost->id }}">
<div class="card card-body mt-2">
@foreach ($historyHost->historyTasks as $historyTasks)
<x-form::checkbox wire:model="test" label="{{$historyTasks->maintenanceTask->task->name}}"/>
{!! $historyTasks->maintenanceTask->task->description !!}
@endforeach
<x-form::form action="save" method="PUT">
@foreach ($maintenance_history->historyHosts as $historyHost)
<div class="mb-3">
<div class="btn-toggle btn py-3 w-100 bg-primary text-start" style="--bs-bg-opacity: .2;" data-bs-toggle="collapse" data-bs-target="#collapse{{ $historyHost->id }}">
<b>{{ $historyHost->host->hostname }}</b>
</div>
<div class="collapse" id="collapse{{ $historyHost->id }}">
<div class="card card-body mt-2">
@foreach ($historyHost->historyTasks as $historyTasks)
<x-form::checkbox wire:model="test" label="{{$historyTasks->maintenanceTask->task->name}}" />
<p>{!! $historyTasks->maintenanceTask->task->description !!}</p>
@endforeach
</div>
</div>
</div>
</div>
@endforeach
@endforeach
<x-form::button class="btn-primary" type="submit">{{ __('Ukončit')}}</x-form::button>
</x-form::form>
</div>
</x-layout-app>

View File

@ -1,8 +1,12 @@
<?php
use App\Jobs\ScheduleNextMaintenance;
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote')->hourly();
// Artisan::command('inspire', function () {
// $this->comment(Inspiring::quote());
// })->purpose('Display an inspiring quote')->hourly();
Schedule::job(new ScheduleNextMaintenance())->daily()->withoutOverlapping();