<?php

use Diglactic\Breadcrumbs\Generator;

Breadcrumbs::for('home', function ( Generator $trail) {
    $trail->push('Home', route('home'));
});

Breadcrumbs::for('entries.index', function ( Generator $trail) {
    $trail->parent('home');
    $trail->push('Database', route('entries.index'));
});

Breadcrumbs::for('entries.show', function ( Generator $trail, string $section, \App\Models\Entry $entry) {
    $trail->parent('entries.index');
    $trail->push($entry->complete_title ?? $entry->title, route('entries.show', [ $section, $entry ] ) );
});
Breadcrumbs::for('entries.drafts', function ( Generator $trail ) {
    $trail->parent('home');
    $trail->push('Drafts', route('entries.drafts'));
});

Breadcrumbs::for('submit.index', function ( Generator $trail ) {
    $trail->parent('home');
    $trail->push('Submit', route('submit.index'));
});
Breadcrumbs::for('submit.create', function ( Generator $trail, string $section ) {
   $trail->parent('home');
   $trail->push('Submit', route('submit.create', [ $section ] ) );
});
Breadcrumbs::for('submit.edit', function ( Generator $trail, string $section, \App\Models\Entry $entry ) {
    $trail->parent('entries.show', $section, $entry);
    $trail->push('Edit', route('submit.edit', [ $section, $entry ] ) );
});

Breadcrumbs::for('news.index', function ( Generator $trail ) {
    $trail->parent('home');
    $trail->push('News', route('news.index'));
});
Breadcrumbs::for('news.show', function ( Generator $trail, \App\Models\News $news ) {
    $trail->parent('news.index');
    $trail->push($news->title, route('news.show', [ $news ] ) );
});
Breadcrumbs::for('news.create', function ( Generator $trail ) {
    $trail->parent('home');
    $trail->push('Submit', route('news.create') );
});
Breadcrumbs::for('news.edit', function ( Generator $trail, \App\Models\News $news ) {
    $trail->parent('news.show', $news);
    $trail->push('Edit', route('news.edit', [ $news ] ) );
});

Breadcrumbs::for('queue.index', function ( Generator $trail ) {
    $trail->parent('home');
    $trail->push('Submissions Queue', route('queue.index') );
});
Breadcrumbs::for('reviews.index', function ( Generator $trail ) {
    $trail->parent('home');
    $trail->push('Reviews', route('reviews.index') );
});
