@extends('layouts.app')
@section('title','Create Book')
@include('layouts.select2')

@section('content')

<div class="row">
    <div class="col-md-12">
        <div class="tile">
            <div class="tile-title-w-btn">
                <h3 class="title"><i class="bi bi-list-ul"></i> {{__('lang.book')}}</h3>
                <a href="{{route('books.index')}}" class="btn btn-primary" title="{{__('lang.books')}}">
                    <i class='bi bi-list'></i>
                </a>
            </div>
            <div class="tile-body">
                <form action="{{route('books.store')}}" method="post">
                    @csrf
                    @include('book.partials._form')
                    <x-buttons.save />
                </form>
                <br>
                @if($lastBook)
                <div class="d-flex justify-content-between align-items-center">
                    <h3>{{__('lang.last_inserted_book')}}</h3>
                    @include('book.partials.actions', ['el' => $lastBook])
                </div>
                <table class="table table-sm table-striped">
                    <tr>
                        <th>ID</th>
                        <td>{{$lastBook->id}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.title')}}</th>
                        <td>{{$lastBook->title}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.category')}}</th>
                        <td>{{$lastBook->category->name}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.location')}}</th>
                        <td>{{$lastBook->location->name}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.language')}}</th>
                        <td>{{$lastBook->language->name}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.author')}}</th>
                        <td>{{$lastBook->author}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.translator')}}</th>
                        <td>{{$lastBook->translator}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.publisher')}}</th>
                        <td>{{$lastBook->publisher}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.isbn')}}</th>
                        <td>{{$lastBook->isbn}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.price')}}</th>
                        <td>{{$lastBook->price}}</td>
                    </tr>
                    <tr>
                        <th>{{__('lang.qty')}}</th>
                        <td>{{$lastBook->qty}}</td>
                    </tr>               
                </table>
                @endif
            </div>
        </div>
    </div>
</div>
@endsection