@extends('backend.layout.master')


@section('content')
    <!--<div class="main-content">-->
        <section class="section">
            <div class="section-header">
                <h1>{{ __($pageTitle) }}</h1>
            </div>

            <div class="row">
                <div class="col-12">

                    <div class="card">
                        <div class="card-header justify-content-end">

                            <div class="d-flex flex-wrap">

                                <?= filterByVariousType([
                                        'model' => 'Ticker',
                                        'text' => [
                                            'placeholder' => 'Search Ticker',
                                            'name' => 'search',
                                            'id' => 'search_text',
                                            'filter_colum' => 'ticker',
                                        ],
                                    ]) ?>

                            </div>


                            <a href="{{ route('admin.ticker.create') }}" class="btn btn-primary add me-2"> <i
                                    class="fa fa-plus"></i>
                                {{ __('Create Ticker') }}</a>


                        </div>
                        <div class="card-body p-0">
                            <div class="table-responsive">
                                <table class="table table-striped" id="table-2">
                                    <thead>
                                        <tr>

                                            <th>{{ __('SL') }}.</th>
                                            <th>{{ __('Date') }}</th>
                                            <th>{{ __('Ticker') }}</th>
                                            <th>{{ __('Position') }}</th>
                                            <th>{{ __('Result') }}</th>
                                            <th>{{ __('User') }}</th>
                                               <th>{{ __('Status') }}</th>
                                             <th>{{ __('Action') }}</th>
                                        </tr>
                                    </thead>
                                    <tbody id="filter_data">

                                        @foreach ($tickers as $ticker)
                                            <tr>
                                                <td>{{ $loop->iteration }}</td>
                                                <td>{{ $ticker->date }}</td>
                                                <td>{{ $ticker->ticker }}</td>
                                                <td>{{ $ticker->position }}</td>
                                              
                                                <td>
                                                   @if($ticker->result === 'Profit')
                                                        <span class="text-success">
                                                            <i data-feather="check-circle"></i> Profit
                                                        </span>
                                                    @elseif($ticker->result === 'Breakeven')
                                                        <span class="text-success">
                                                            <i data-feather="check-circle"></i> Breakeven
                                                        </span>
                                                    @else
                                                        <span class="text-danger">
                                                            <i data-feather="x-circle"></i> Loss
                                                        </span>
                                                    @endif
                                                </td>
                                                 <td>
                                                    @if($ticker->user_id === 'All')
                                                        <span class="badge badge-info">All Users</span>
                                                    @elseif($ticker->user)
                                                        {{ $ticker->user->fname }} {{ $ticker->user->lname }}
                                                    @else
                                                        <span class="text-muted">User not found</span>
                                                    @endif
                                                </td>
                                             <td>{{ $ticker->status }}</td>

                                                <td>
                                                    <a href="{{ route('admin.ticker.edit', $ticker) }}"
                                                        class="btn btn-primary btn-sm"><i class="fa fa-pen"></i></a>
                                                </td>

                                            </tr>
                                        @endforeach


                                    </tbody>
                                </table>
                            </div>
                        </div>

                        @if ($tickers->hasPages())
                            <div class="card-footer">
                                {{ $tickers->links('backend.partial.paginate') }}
                            </div>
                        @endif
                    </div>
                </div>
            </div>

        </section>
    <!--</div>-->
@endsection

@push('style-plugin')
    <link rel="stylesheet" href="{{ asset('asset/admin/css/select2.min.css') }}">
@endpush

@push('script-plugin')
    <script src="{{ asset('asset/admin/js/select2.min.js') }}"></script>
@endpush

@push('script')
 
@endpush
