<div class="panel panel-primary">
  <div class="panel-heading">
    <h2>@lang('backend.page-name')</h2>
  </div>
  {!! Form::open(['url' => route('savePageName'),'method' => 'post']) !!}
    <div class="panel-body">
      @if(Session::has('message-pagename'))
        <div id="message-pagename" class="alert {{ Session::get('alert-class') }} alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <p>{{ Session::get('message-pagename') }}</p>
        </div>
      @endif

      @foreach ($pageName as $key => $value)
        <div class="panel panel-primary">
          <div class="panel-heading">
            <h3>{{ ucwords(str_replace('-',' ',$value->key)) }}</h3>
          </div>
          <div class="panel-body">
            @foreach (config('translatable.locales') as $lang => $language)
              @php
                $locale = App\Pagename::find($value->id)->locales()->where('locale',$lang)->first();
                if(count(config('translatable.locales')) > 1){
                  $name = "Name [".$language."]";
                }else{
                  $name = "Name";
                }

                if(empty($locale)){
                  $pagename = "";
                }else{
                  $pagename = $locale->page_name;
                }
              @endphp
              <div class="form-group col-xs-12 col-sm-6">
                {!! Form::label('pagename',$name,['class'=>'control-label']) !!}
                {!! Form::text('pagename['.$value->id.']['.$lang.']',$pagename,['class'=>'form-control']) !!}
              </div>
            @endforeach
          </div>
        </div>
      @endforeach
    </div>
    <div class="modal-footer">
      <button type="submit" class="btn btn-primary">@lang('backend.update')</button>
    </div>
  {!! Form::close() !!}
</div>
