<?php

// routes/breadcrumbs.php

// Note: Laravel will automatically resolve `Breadcrumbs::` without
// this import. This is nice for IDE syntax and refactoring.
use App\Models\Client;
use App\Models\ClientCase;
use App\Models\ImportTemplate;
use App\Models\Segment;
use Diglactic\Breadcrumbs\Breadcrumbs;
// This import is also not required, and you could replace `BreadcrumbTrail $trail`
//  with `$trail`. This is nice for IDE type checking and completion.
use Diglactic\Breadcrumbs\Generator as BreadcrumbTrail;

// Dashboard > Notifications (Unread)
Breadcrumbs::for('notifications.unread', function (BreadcrumbTrail $trail): void {
    $trail->parent('dashboard');
    $trail->push('Obvestila', route('notifications.unread'));
});

Breadcrumbs::for('settings.contractConfigs.index', function (BreadcrumbTrail $trail): void {
    $trail->parent('settings');
    $trail->push('Contract Configs', route('settings.contractConfigs.index'));
});

// Dashboard > Settings > Archive
Breadcrumbs::for('settings.archive.index', function (BreadcrumbTrail $trail): void {
    $trail->parent('settings');
    $trail->push('Arhiv', route('settings.archive.index'));
});

// Dashboard > Settings > Reports
Breadcrumbs::for('settings.reports.index', function (BreadcrumbTrail $trail): void {
    $trail->parent('settings');
    $trail->push('Reports', route('settings.reports.index'));
});

// Dashboard
Breadcrumbs::for('dashboard', function (BreadcrumbTrail $trail) {
    $trail->push('Nadzorna plošča', route('dashboard'));
});

// Dashboard > Clients
Breadcrumbs::for('client', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Naročniki', route('client'));
});

// Dashboard > Clients > [Client]
Breadcrumbs::for('client.show', function (BreadcrumbTrail $trail, Client $client) {
    $trail->parent('client');
    $trail->push($client->person->full_name, route('client.show', $client));
});

// Dashboard > Clients > [Client] > Contracts
Breadcrumbs::for('client.contracts', function (BreadcrumbTrail $trail, Client $client) {
    $trail->parent('client.show', $client);
    $trail->push('Pogodbe', route('client.contracts', $client));
});

// Dashboard > Cases

Breadcrumbs::for('clientCase', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Primeri', route('clientCase'));
});

// Dashboard > Cases > [Case]

Breadcrumbs::for('clientCase.show', function (BreadcrumbTrail $trail, ClientCase $clientCase) {
    $trail->parent('clientCase');
    $trail->push($clientCase->person->full_name, route('clientCase.show', $clientCase));
});

// Dashboard > Settings
Breadcrumbs::for('settings', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Nastavitve', route('settings'));
});

// Dashboard > Settings > Segments
Breadcrumbs::for('settings.segments', function (BreadcrumbTrail $trail) {
    $trail->parent('settings');
    $trail->push('Segmenti', route('settings.segments'));
});

// Dashboard > Settings > Workflow
Breadcrumbs::for('settings.workflow', function (BreadcrumbTrail $trail) {
    $trail->parent('settings');
    $trail->push('Potek dela', route('settings.workflow'));
});

// Dashboard > Settings > Field Job
Breadcrumbs::for('settings.fieldjob.index', function (BreadcrumbTrail $trail) {
    $trail->parent('settings');
    $trail->push('Terensko delo', route('settings.fieldjob.index'));
});

// Dashboard > Settings > Payments
Breadcrumbs::for('settings.payment.edit', function (BreadcrumbTrail $trail) {
    $trail->parent('settings');
    $trail->push('Plačila', route('settings.payment.edit'));
});

// Dashboard > Segments
Breadcrumbs::for('segments.index', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Segmenti', route('segments.index'));
});

// Dashboard > Segments > [Segment]
Breadcrumbs::for('segments.show', function (BreadcrumbTrail $trail, Segment $segment) {
    $trail->parent('segments.index');
    $trail->push($segment->name, route('segments.show', $segment));
});

// Dashboard > Field Jobs
Breadcrumbs::for('fieldjobs.index', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Terenska dela', route('fieldjobs.index'));
});

// Dashboard > Reports

Breadcrumbs::for('reports.index', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Poročila', route('reports.index'));
});

// Dashboard > Reports > [Report]

Breadcrumbs::for('reports.show', function (BreadcrumbTrail $trail, string $slug) {
    $trail->parent('reports.index');
    $report = \App\Models\Report::where('slug', $slug)->first();
    $trail->push($report?->name ?? $slug, route('reports.show', $slug));
});

// Dashboard > Imports

Breadcrumbs::for('imports.index', function (BreadcrumbTrail $trail) {
    $trail->parent('dashboard');
    $trail->push('Uvozi', route('imports.index'));
});

// Dashboard > Imports > Templates

Breadcrumbs::for('importTemplates.index', function (BreadcrumbTrail $trail) {
    $trail->parent('imports.index');
    $trail->push('Uvozne predloge', route('importTemplates.index'));
});


// Dashboard > Imports > Templates > Create

Breadcrumbs::for('importTemplates.create', function (BreadcrumbTrail $trail) {
    $trail->parent('importTemplates.index');
    $trail->push('Ustvari', route('importTemplates.create'));
});


// Dashboard > Imports > Templates > Edit > [Template]

Breadcrumbs::for('importTemplates.edit', function (BreadcrumbTrail $trail, ImportTemplate $template) {
    $trail->parent('importTemplates.index');
    $trail->push($template->name, route('importTemplates.edit', $template));
});
