@extends('layouts.main')

@section('content')
<!--**********************************
Content body start
***********************************-->
<span class="display-zero">{{ $Locale = LaravelLocalization::getCurrentLocale() }}</span>
<div class="content-body">
    <div class="container-fluid">
        <div class="row page-titles mx-0">
            <div class="col-sm-6 p-md-0">
                <div class="welcome-text">
                    <h4></h4>
                    <p class="mb-0">{!! COUNT($Cars) !!} {{ __('main.We_provide')}}</p>
                </div>
            </div>
            <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
            <ol class="breadcrumb">
             <li class="breadcrumb-item"><a href="{!! url('') !!}">{{ __('main.Home')}}</a></li>
             <li class="breadcrumb-item active"><a>{{ __('main.Cars')}}</a></li>
            </ol>
            </div>
        </div>
        <div class="row">
            @foreach($car_ads as $car)
                <?php 
                    $image = json_decode($car->car_images);
                    if(count($image) > 0)
                        $d_image = $image[0];
                    else
                        $d_image = 'no-image.png';
                ?>
                <div class="col-lg-4 col-xl-4 mb-3">
                    <div class="card">
                        <div class="card-body">
                            <div class="row m-b-30">
                                <div class="col-md-5 col-xxl-12">
                                    <div class="new-arrival-product mb-4 mb-xxl-4 mb-md-0">
                                        <div class="new-arrivals-img-contnent">
                                            <a href="{{ url('Cars') }}/{{$car->id}}">
                                            <img class="img-fluid rounded" 
                                                 src="{{asset('assets/car_images/'.$d_image)}}" 
                                                 alt="{{$car->car_brand->Title_en}}" style="height: 220px;" />
                                            </a>
                                        </div>
                                    </div>
                                </div> 
                                <div class="col-md-7 col-xxl-12">
                                    <div class="new-arrival-content position-relative">
                                        <h4>{{$car->car_brand->Title_en.' '.$car->car_model($car->car_model_id)->title}}</h4>
                                        <p class="price">€ {{' '.$car->whish_price}}</p>
                                <p>{{ __('First Registration')}} <span class="item">{{$car->registration_month.' '.$car->registration_year}}</span></p>
                                {{-- <p>{{ __('main.Brand')}} <span class="item">
                                        @if(isset($Car->Category->{'Title_'.$Locale}))
                                           {{ $Car->Category->{'Title_'.$Locale} }}
                                        @else
                                        @endif
                                </span></p> --}} 
                                <p class="text-content">{!! substr($car->other_specs , 0, 190) !!}</p>
                                        @if($car->is_sold == 1)
                                        <div class="comment-review star-rating text-right">
                                            <ul>
                                                <span class="label label-danger" style="border-radius: 25px;">{{__('Sold')}}</span>
                                            </ul>
                                        </div>
                                        @endif
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            @endforeach
            {{-- @foreach($Cars as $Car)
            <div class="col-lg-4 col-xl-4 mb-3">
                <div class="card">
                    <div class="card-body">
                        <div class="row m-b-30">
                            <div class="col-md-5 col-xxl-12">
                                <div class="new-arrival-product mb-4 mb-xxl-4 mb-md-0">
                                    <div class="new-arrivals-img-contnent">
                                        <a href="{{ url('Cars') }}/{{$Car->slug}}">
                                        <img class="img-fluid rounded" 
                                             src="{{ asset($Car->ImageUpload->filename) }}" 
                                             alt="{{ $Car->meta_description }}"/>
                                        </a>
                                    </div>
                                </div>
                            </div> 
                            <div class="col-md-7 col-xxl-12">
                                <div class="new-arrival-content position-relative">
                                    <h4>{{ $Car->{'Title_'.$Locale} }}</h4>
                                    <p class="price">{!! $Car->seo_title !!}</p>
                            <p>{{ __('main.Product_Code')}} <span class="item">{!! $Car->meta_keywords !!}</span></p>
                            <p>{{ __('main.Brand')}} <span class="item">
                                    @if(isset($Car->Category->{'Title_'.$Locale}))
                                       {{ $Car->Category->{'Title_'.$Locale} }}
                                    @else
                                    @endif
                            </span></p>
                            <p class="text-content">{!! substr($Car->{'body_'.$Locale} , 0, 190) !!}</p>
                                    <div class="comment-review star-rating text-right">
                                        <ul>
                                            {!! $Car->meta_description !!}  {{ __('main.Reviews')}}
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @endforeach --}}
                {{-- <div class="col-xl-12 col-xxl-12 col-lg-12 col-md-12">
                    <div class="card bg-secondary" style="background-image:url('{{ asset(option('covernew')) }}'); background-repeat:no-repeat;background-size: cover;">
                        <div class="card-body p-5 mt-3">
                            <h2 class="text-white mb-3">{{ __('main.Have_question')}}</h2>
                <a href="{{ url('Contacts') }}" class="d-flex text-light align-items-center justify-content-between">
                                <small>{{ option('PhoneNumber') }}</small>
                                <i class="ti-arrow-right"></i>
                            </a>
                        </div>
                    </div>
                </div> --}}
            </div>
        </div>
    </div>
<!--**********************************
      Content body end
***********************************-->
@endsection