@extends('layouts.default')
@extends('content_wrappers.md-10')

@section('title', ' | '.$recipe->name)
@section('heading')
  @if(Auth::user() && (in_array('EditRecipe',$allperms) || $recipe->user_id == Auth::user()->id))
    <a href="{{ route('recipes.edit', $recipe->id) }}">{{$recipe->name}}</a>
  @else
    {{$recipe->name }}
  @endif
@endsection

@section('content')
<div class="panel-body">
    <div class="row">
        <div class="col-md-3 text-center">Created By: {{$recipe->author}}</div>
        <div class="col-md-3 text-center">Maintained By: {{$recipe->user->name}}</div>

        <div class="col-md-3 text-center">Entered On: {{$recipe->date_entered->format('Y/m/d') }}</div>
        <div class="col-md-3 text-center">Last Changed: {{$recipe->date_modified->format('Y/m/d') }}</div>
    </div>
    <div class="row">
        <div class="col-sm-offset-3 col-sm-3 text-center">Servings: {{$recipe->servings}}</div>
        <div class="col-sm-3 text-center">Serving Size: {{$recipe->serving_size}}</div>
    </div>
    <br />
    <div class="row"><div class="panel-heading"><h1>Categories</h1></div></div>
    <div class="row text-center">@foreach ($recipe->categories as $index => $category){{($index != 0 ? ", " : "").ucwords($category->name)}}@endforeach</div>
    <br />
    <div class="row"><div class="panel-heading"><h1>Description</h1></div></div>
    <div class="row"><div class="col-sm-offset-2 col-lg-8">{!!$recipe->description!!}</div></div class="row">
    <br />
    <div class="row"><div class="panel-heading"><h1>Ingredients</h1></div></div>

    @foreach ($recipe->ingredients as $index => $ingredient)
        @if ($ingredient->alternative)
            OR {{$ingredient->quantity}} {{$ingredient->measurement}} {{$ingredient->name}}
        @else
            @if($index != 0) </div> @endif
            <div class="col-sm-offset-2 col-lg-4">{{$ingredient->quantity}} {{$ingredient->measurement}} {{$ingredient->name}}
        @endif
    @endforeach
    @if(count($recipe->ingredients) > 0)
        </div>
    @endif

    <br /><br />
    <div class="row"><div class="panel-heading"><h1>Instructions</h1></div></div>
    <div class="row"><div class="col-sm-offset-1 col-lg-10">{!!$recipe->instructions!!}</div>
</div>
@endsection
