ldc-legaulois/resources/views/front/recipes/show.blade.php
2021-06-16 10:10:39 +02:00

225 lines
9.6 KiB
PHP

@php
$vegetal = ($recipe->products->first()->range->slug ?? '') == 'le-vegetal';
@endphp
@extends('layouts.app', ['brParam' => $recipe, 'vegetal' => $vegetal])
@section('title', strlen($recipe->seo_title) ? $recipe->seo_title : $recipe->title)
@section('description', strlen($recipe->seo_description) ? $recipe->seo_description : ($recipe->catch_phrase ?? $recipe->title))
@section('breadcrumb', request()->route()->getName())
@section('bg-color', 'white-bg recipeShow')
@section('microdata')
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Recipe",
"description": "{{ strlen($recipe->catch_phrase) ? $recipe->catch_phrase : ($recipe->seo_description ?? $recipe->title) }}",
"image": "{{ url($recipe->picture) }}",
"name": "{{ strlen($recipe->title) ? $recipe->title : $recipe->seo_title }}",
@if(strlen($recipe->ingredients))
"recipeIngredient": "{!! trim(preg_replace('/\s\s+/', ' ', str_replace('"', '\"', $recipe->ingredients))) !!}",
@endif
@if($recipe->preparation_time)
"prepTime": "PT{{ $recipe->preparation_time }}M",
@endif
@if($recipe->cooking_time)
"cookTime" : "PT{{ $recipe->cooking_time }}M",
@endif
@if(strlen($recipe->preparation))
"recipeInstructions": "{!! str_replace('"', '\"', trim(preg_replace('/\s\s+/', ' ', $recipe->preparation))) !!}",
@endif
"totalTime": "PT{{ ($recipe->cooking_time ?? 0) + ($recipe->preparation_time ?? 0) }}M",
"recipeCategory": "Main Dish",
"author": "Le Gaulois",
"nutrition": "",
"keywords": "{{ trim(preg_replace('/\s\s+/', ' ', str_replace(';', ',', str_replace('"', '\"', $recipe->tags)))) }}"
}
</script>
@endsection
@section('sub_header')
<div class="sub_header sub_header_recipe @if(($recipe->products->first()->range->slug ?? '') =='le-vegetal' )vegetal @endif">
<div class="recipeVisualHeader">
@if($recipe->type->equals(RecipeType::video()))
<iframe src="{{ $recipe->video_link }}?autoplay=1&color=ff9933&title=0&byline=0" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
@else
<img src="{{ $recipe->picture }}" alt="{{ $recipe->title }}" />
@endif
</div>
<div class="recipeDetailHeader">
<h1>{{ $recipe->title }}</h1>
@if(strlen($recipe->tags))
<div class="recipeTags">
@foreach(explode(';', $recipe->tags) as $tag)
@if(strlen($tag))
<div class="recipeTag">{{ $tag }}</div>
@endif
@endforeach
</div>
@endif
<div class="recipeIcons">
@if($recipe->number_people)
<div class="persons">
<i class="icon-notes"></i>
<h5>{{ __(':count personne(s)', ['count' => $recipe->number_people]) }}</h5>
</div>
@endif
@if($recipe->preparation_time)
<div class="preptime">
<i class="icon-preparation"></i>
<h5>{!! sprintf(__(':time min %s de préparation', ['time' => $recipe->preparation_time]), '<br>') !!}</h5>
</div>
@endif
@if($recipe->cooking_time)
<div class="cooktime">
<i class="icon-cuisson"></i>
<h5>{!! sprintf(__(':time min %s de cuisson', ['time' => $recipe->cooking_time]), '<br>') !!}</h5>
</div>
@endif
<div class="difficulty">
<div class="{{ $recipe->difficulty->getDefinition() }}">
@for($i = 0; $i < $recipe->difficulty->value; $i++)
<i class="icon-difficulte"></i>
@endfor
</div>
<h5>{{ $recipe->difficulty }}</h5>
</div>
</div>
</div>
</div>
@endsection
@section('content')
<div class="content recipe @if($vegetal)vegetal @endif">
<div class="share">
<a class="mediaShare" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={{ request()->fullurl() }}&title={{ $recipe->title }}" title="{{ __('Partager sur Facebook') }}">
<i class="fab fa-facebook-f"></i>
</a>
<a class="mediaShare" target="_blank" href="https://pinterest.com/pin/create/button/?url={{ request()->fullurl() }}&media={{ $recipe->picture }}&description={{ $recipe->title }}" title="{{ __('Partager sur Pinterest') }}">
<i class="fab fa-pinterest"></i>
</a>
<a href="https://www.instagram.com/legaulois_officiel/" target="_blank">
<i class="fab fa-instagram"></i>
</a>
@if(auth('customer')->check())
<span id="setFavorite"><i class="icon-favorite @if(auth('customer')->user()->hasRecipe($recipe))active @endif"></i></span>
@else
<a href="{{ route('form-connexion') }}"><i class="icon-favorite"></i></a>
@endif
<span class="printRecipe"><i class="icon-print"></i></span>
</div>
@if($recipe->ingredients)
<aside class="ingredients">
@if(count($recipe->products))
<figure>
@foreach($recipe->products as $product)
<img src="{{ $product->picture }}" alt="{{ $product->name }}" />
@endforeach
</figure>
@endif
<h3>{{ __('Ingrédients') }}</h3>
<div>{!! clean($recipe->ingredients) !!}</div>
</aside>
@endif
<section>
@if(strlen($recipe->catch_phrase))
<header>
<h2>"{{ $recipe->catch_phrase }}"</h2>
</header>
@endif
@if(strlen($recipe->preparation))
<article class="preparation">
<h3>{{ __('Préparation') }}</h3>
<div>{!! clean($recipe->preparation) !!}</div>
</article>
@endif
@if(strlen($recipe->advice))
<article class="advice">
<h3>{{ __('Le Conseil Le Gaulois') }}</h3>
<div>{!! clean($recipe->advice) !!}</div>
</article>
@endif
@if(count($recipe->articles))
<article class="tips">
<h3>{{ __('Astuces Associées') }}</h3>
@foreach($recipe->articles as $article)
<div class="tip">
<a href="{{ route('club.infos.child', $article->slug) }}" title="{{ $article->title }}">
<figure><img src="{{ $article->picture }}" alt="{{ $article->title }}" /></figure>
<p>{{ $article->title }}</p>
</a>
</div>
@endforeach
</article>
@endif
</section>
<footer>
<div class="rating">
<h5>{{ __('Évaluez cette recette ') }}</h5>
<div id="rater" data-rating="{{ $recipe->getUserRating() }}" @if($recipe->hasBeenRatedByUser()) data-disable="true" @endif></div>
<h5 class="ratingShare">{{ __('Partager') }}</h5>
<a target="_blank" class="mediaShare facebook-item" href="https://www.facebook.com/sharer/sharer.php?u={{ request()->fullurl() }}&title={{ $recipe->title }}" title="{{ __('Partager sur Facebook') }}">
<i class="fab fa-facebook-f"></i>
</a>
<a href="https://www.instagram.com/legaulois_officiel/" target="_blank">
<i class="fab fa-instagram"></i>
</a>
<a target="_blank" class="mediaShare twitter-item" href="https://twitter.com/share?url={{ request()->fullurl() }}" title="{{ __('Partager sur Twitter') }}">
<i class="fab fa-twitter"></i>
</a>
</div>
<div class="buttons">
<span class="btn_cplm printRecipe" title="{{ __('Imprimer la recette') }}">
{!! sprintf(__('Imprimer %sla recette%s'), '<span>','</span>') !!}</span>
@if(auth('customer')->check() and auth('customer')->user()->hasRecipe($recipe))
<a href="{{ auth('customer')->check() ? route('account.favs-recipes') : route('form-connexion') }}" class="btn_cplm favoriteRecipe favRecipeBtn" title="{{ __('Recettes favorites') }}">
{!! sprintf(__('Recettes %sfavorites%s'), '<span>','</span>') !!}</a>
@endif
<a href="{{ route('recipes.propose') }}" class="btn_cplm proposeRecipe" title="{{ __('Proposer une recette') }}">{!! sprintf(__('Proposer %sune recette%s'), '<span>','</span>') !!}</a>
</div>
</footer>
</div>
<div class="associatedRecipe">
<div class="list-wrapper">
<h3>{{ __('Recettes qui pourraient vous intéresser') }}</h3>
<div class="list-recipe">
@foreach($recipe->associatedRecipes() as $rcp)
<div class="wrap_recipe">
<a href="{{ route('recipes.show', $rcp) }}">
<figure>
<div class='hoverFigure'>
<h5>{{ __('Voir la recette !') }}</h5>
</div>
<img src="{{ $rcp->picture }}" alt="{{ $rcp->title }}" />
</figure>
<p>{{ $rcp->title }}</p>
<p>{{ $rcp->catch_phrase }}</p>
</a>
</div>
@endforeach
</div>
</div>
</div>
@endsection
@push('scriptsConstants')
<script>
window._locale = '{{ app()->getLocale() }}';
window._translations = @json(cache(sprintf('translations.%s', app()->getLocale())));
window._routes = {
"recipes.rate": "{{ route('recipes.rate', $recipe) }}",
"account.favs-recipes": "{{ route('account.favs-recipes') }}",
"account.add-favs-recipes": "{{ route('account.set-favs-recipes', ['recipe' => $recipe, 'status' => 1]) }}",
"account.remove-favs-recipes": "{{ route('account.set-favs-recipes', ['recipe' => $recipe, 'status' => 0]) }}"
};
</script>
@endpush