@foreach($vacancies as $vacancy)
<?php
    if ($vacancy->flexible_location) {
        if ($vacancy->offices->count() == 0) {
            $country = 'flexible';
        } else {
            $countries = [];
            $vacancy->offices->each(function ($office) use (&$countries) {
                $countries[] = $office->country->title;
            });
            $country = implode(';', $countries);
        }
    } else {
        $country = $vacancy->office && $vacancy->office->country ? $vacancy->office->country->title : '';
    }
?>
<div class="tile-wrapper job-block" data-filterCountry="{{ $country }}" data-filterUnit="{{ $vacancy->business_unit }}">
    <div class="row item no-gutter"> 
        <div class="col-lg-offset-3 col-lg-17 col-sm-offset-2 col-sm-20 col-xs-24">
            <div class="relative">
                <h2>{{$vacancy->title}}</h2>
                <div class="info">
                    @if($vacancy->flexible_location)
                        <span class="name">@lang('Location flexible'):
                            @foreach($vacancy->offices as $i => $office)
                                {{ $office->city }}@if($i < ($vacancy->offices->count() - 1)),@endif
                            @endforeach
                        </span>
                    @elseif($vacancy->office)
                        <span class="name">{{$vacancy->office->title}}</span>
                    @endif
                    <span class="name">
                        @lang('Job ID:') {{ $vacancy->id }}
                    </span>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-sm-2">
            <div class="buttons-placeholder">
                @include('frontend.templates.components.share_button_small', array(
                'shareTitle' => strip_tags($vacancy->title),
                'shareDescription' => strip_tags($vacancy->description),
                'shareUrl' => lang_url($vacancy->lang_uri)
                ))

                @if($vacancy->document)
                <a target="_blank" class="download-pub" href="{{ url('/uploads/media/' . $vacancy->document->filename) }}">
                </a>
                @endif
            </div>
        </div>
    </div>
    <div class="row item margin-between-items no-gutter">
        <div class="col-lg-offset-3 col-lg-17 col-sm-offset-2 col-sm-20 p-margin-top">
            <p>{{ strip_tags($vacancy->description) }}</p>
            <div class="read-more">
                <a href="{{ lang_url($vacancy->lang_uri) }}">
                    Read more
                </a>
                <a class="apply-now-link" href="{{ lang_url($vacancy->lang_uri) }}#apply">
                    @lang('Apply now')
                </a>
            </div>
        </div>
    </div>
</div>
@endforeach