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 public function run(): void
{ {
// User::factory(10)->create(); // 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([ $this->call([
'name' => 'Test User', HostSeeder::class,
'email' => 'test@example.com', 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> <h1>{{ __('Planned Maintenance') }}</h1>
</div> </div>
<p>{!! $maintenance_history->maintenance->description !!}</p> <p>{!! $maintenance_history->maintenance->description !!}</p>
@foreach ($maintenance_history->historyHosts as $historyHost) <x-form::form action="save" method="PUT">
<div class="mb-3"> @foreach ($maintenance_history->historyHosts as $historyHost)
<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 }}"> <div class="mb-3">
<b>{{ $historyHost->host->hostname }}</b> <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 }}">
</div> <b>{{ $historyHost->host->hostname }}</b>
<div class="collapse" id="collapse{{ $historyHost->id }}"> </div>
<div class="card card-body mt-2"> <div class="collapse" id="collapse{{ $historyHost->id }}">
@foreach ($historyHost->historyTasks as $historyTasks) <div class="card card-body mt-2">
<x-form::checkbox wire:model="test" label="{{$historyTasks->maintenanceTask->task->name}}"/> @foreach ($historyHost->historyTasks as $historyTasks)
{!! $historyTasks->maintenanceTask->task->description !!} <x-form::checkbox wire:model="test" label="{{$historyTasks->maintenanceTask->task->name}}" />
@endforeach <p>{!! $historyTasks->maintenanceTask->task->description !!}</p>
@endforeach
</div>
</div> </div>
</div> </div>
</div> @endforeach
@endforeach <x-form::button class="btn-primary" type="submit">{{ __('Ukončit')}}</x-form::button>
</x-form::form>
</div> </div>
</x-layout-app> </x-layout-app>

View File

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