syntax error, unexpected end of file laravel

0

Well my query is because I read my code a thousand times and I do not know where the error is, I have a pure php app that I'm trying to integrate with laravel but I can not find the error of syntax error, unexpected end of file

create the model, the view and the controller, until there all right but when reflecting the data through a SENDER, I throw the error, I read the code and can not find where the error is:

 @section('titulo')
<h1>Crear Firma</h1>
@endsection

@section('content')
@if (Auth::check())
   @if(Auth::user()->firmas == 1)
   @if(!empty($_REQUEST['Sender'])):
    $sender = $_REQUEST['Sender'];
    $layout = file_get_contents('$datos->plantilla', FILE_USE_INCLUDE_PATH);

    @foreach ($sender as $key => $value) {
        $key         = strtoupper($key);
        $start_if    = strpos($layout, '[[IF-' . $key . ']]');
        $end_if      = strpos($layout, '[[ENDIF-' . $key . ']]');
        $length      = strlen('[[ENDIF-' . $key . ']]');

        @if (!empty($value)) {
            // Add the value at its proper location.
            $layout = str_replace('[[IF-' . $key . ']]', '', $layout);
            $layout = str_replace('[[ENDIF-' . $key . ']]', '', $layout);
            $layout = str_replace('[[' . $key . ']]', $value, $layout);
        } @elseif (is_numeric($start_if)) {
            // Remove the placeholder and brackets if there is an if-statement but no value.
            $layout = str_replace(substr($layout, $start_if, $end_if - $start_if + $length), '', $layout);
        } @else {
            // Remove the placeholder if there is no value.
            $layout = str_replace('[[' . $key . ']]', '', $layout);
        }
    }

    // Clean up any leftover placeholders. This is useful for booleans,
    // which are not submitted if left unchecked.
    $layout = preg_replace("/\[\[IF-(.*?)\]\]([\s\S]*?)\[\[ENDIF-(.*?)\]\]/u", "", $layout);

    @if (!empty($_REQUEST['download'])) {
        header('Content-Description: File Transfer');
        header('Content-Type: text/html');
        header('Content-Disposition: attachment; filename=efirma.html');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    }
    @if (!empty($_REQUEST['Guardar'])) {
        header('Content-Description: File Transfer');
        header('Content-Type: text/html');
        header('Content-Disposition: attachment; filename=efirma.html');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    }
    echo $layout;
@else: }}
                        <form name="formulario" role="form" class="form-horizontal" method="post" target="preview" id="form">
                    <div class="form-group row">
                        <label for="nombre_cliente" class="col-md-1 control-label">Nombre</label>
                        <div class="col-md-3">
                        <input type="text" class="form-control input-sm" id="nombre_cliente" name="Sender[nombre]" placeholder="Selecciona un empleado" required>
                      <input id="id_cliente" type='hidden'>
                    </div>
                        <label for="Puesto" class="col-md-1 control-label">Puesto</label>
                        <div class="col-md-3">
                        <input type="puesto" class="form-control" id="puesto" name="Sender[puesto]" placeholder="Gerente administrativo"  readonly>
                    </div>
                        <label for="Email" class="col-md-1 control-label">Correo</label>
                        <div class="col-md-3">
                        <input type="email" class="form-control" id="email_cliente" name="Sender[correo]" placeholder="Ingresa tu Email" readonly>
                    </div>
                    </div>
                    <div class="form-group row">
                        <label for="Telefono" class="col-md-1 control-label">Telefono</label>
                        <div class="col-md-3">
                        <input type="telefono" class="form-control" id="telefono" name="Sender[telefono]" placeholder="+XX (XXX) XXX-XXXX" readonly="" value="{{ $datos->telefono_empleado }}">
                    </div>
                    <label for="Celular" class="col-md-1 control-label">Celular</label>
                        <div class="col-md-3">
                        <input type="celular" class="form-control" id="telefono_cliente" name="Sender[celular]" placeholder="+XX (XXX) XXX-XXXX" readonly>
                        </div>
                    <label for="Sitio" class="col-md-1 control-label">Sitio web</label>
                        <div class="col-md-3">
                        <input type="sitio" class="form-control" id="Sitio" name="Sender[sitio]" placeholder="www.ejemplo.com" value="{{ $datos->sitio_web }}" readonly>
                    </div>
                    </div>
                    <div class="form-group row">
                        <label for="Direccion" class="col-md-1 control-label">Direccion</label>
                        <div class="col-md-3">
                        <input type="direccion" class="form-control" id="direccion" name="Sender[calle]" placeholder="Av. Paseo Centenario 303310" value="{{ $datos->direccion }}" readonly>
                    </div>
                        <label for="Colonia" class="col-md-1 control-label">Colonia</label>
                        <div class="col-md-3">
                        <input type="colonia" class="form-control" id="Colonia" name="Sender[colonia]" placeholder="Zona Urbana Rio" value="{{ $datos->colonia }}" readonly>
                        </div>
                        <label for="Ciudad" class="col-md-1 control-label">Ciudad</label>
                        <div class="col-md-3">
                        <input type="ciudad" class="form-control" id="Ciudad" name="Sender[ciudad]" placeholder="Tijuana, B.C." value="{{ $datos->ciudad }}" readonly>
                    </div>
                    </div>
                    <div class="form-group row">
                    <label for="codigo" class="col-md-1 control-label">Codigo Postal</label>
                        <div class="col-md-3">
                        <input type="codigo" class="form-control" id="Codigo" name="Sender[codigo]" placeholder="22245" value="{{ $datos->codigo_postal }}" readonly>
                    </div>
                    <label for="facebook" class="col-md-1 control-label">Facebook</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Facebook" name="Sender[facebook]"    value="{{ $datos->facebook }}"  readonly>
                    </div>
                    <label for="instagram" class="col-md-1 control-label">Instagram</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Instagram" name="Sender[instagram]"  value="{{ $datos->instagram }}"  readonly>
                    </div>
                    <label for="twitter" class="col-md-1 control-label">Twitter</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Twitter" name="Sender[twitter]"    value="{{ $datos->twitter }}"  readonly>
                    </div>
                    <label for="youtube" class="col-md-1 control-label">Youtube</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Youtube" name="Sender[youtube]"    value="{{ $datos->youtube }}"  readonly>
                    </div>
                    </div>
                    <div class="form-group row">
                    <label for="linkedin" class="col-md-1 control-label">Linkedin</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Linkedin" name="Sender[linkedin]"    value="{{ $datos->Linkedin }}"  readonly>
                    </div>
                    <label for="google" class="col-md-1 control-label">Google+</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Google" name="Sender[google]"   value="{{ $datos->google_plus }}"  readonly>
                    </div>
                    <label for="pinterest" class="col-md-1 control-label">Pinterest</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Pinterest" name="Sender[pinterest]"    value="{{ $datos->pinterest }}"  readonly>
                    </div>
                    <label for="flickr" class="col-md-1 control-label">Flickr</label>
                        <div class="col-md-1">
                        <input type="checkbox" class="form-control" id="Flickr" name="Sender[flickr]"    value="{{ $datos->flickr }}"  readonly>
                    </div>
                    </div>

                    <div class="col-md-12">
                    <div class="pull-right">
                        <button id="preview" type="submit" class="btn btn-default" onclick="capturar()">
                          <span class="glyphicon glyphicon-refresh"></span> Ver Firma
                        </button>
                        <button id="download" class="btn btn-default" > Descargar Firma</button>
                        <input type="hidden" name="download" id="will-download" value="">
                        <button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">
             <span class="glyphicon glyphicon-search"></span> Catalogo de empleados
            </button>
                    </div>  
                </div>
                </form>
  </div>    
      <div class="row-fluid">
      <div class="col-md-12">
@endif
                    @else
                    <h1>No tienes permisos para ver este modulo</h1>
                        <a href="{{ url('/register') }}">Comprar Modulo de firmas</a>
                    @endif

@endif
@endsection

I hope someone can help me because he's driving me crazy!

    
asked by Abdiel Hernandez 09.07.2018 в 04:34
source

1 answer

1

If you check the Laravel documentation , you will find that you are making some mistakes.

To get started if you want to include php in your view you should use @php before the code block and close it with @endphp , for example in your code you should have this in one of your lines:

@php 
    $layout = preg_replace("/\[\[IF-(.*?)\]\]([\s\S]*?)\[\[ENDIF-(.*?)\]\]/u", "", $layout);
@endphp

Also where you try to do a echo you can use the php block, but it would be meaningless, instead you can use the javascript console or show the data using the blade, which provides you with different options , so instead of your echo $layout; you could do something like that or in any case delete that line:

{{ $layout }}

Another small detail is that you are using : after an else, I do not know what you are trying there but it is incorrect ( @else: ), you should delete it.

In general, the structure of your code as mentioned in the comments is poorly written, check the documentation on conditional and you will realize that all @if always closes with a @endif without using keys { , } and inside can contain as many @else and @elseif as desired. The same for loops @foreach .

Well, trying to understand the structure of your code and removing the irrelevant I suggest this structure, review it and adapt it to your code if it is not the one you want to achieve.

@section('titulo')
<h1>Crear Firma</h1>
@endsection

@section('content')

@if (Auth::check())

   @if(Auth::user()->firmas == 1)
      @if(!empty($_REQUEST['Sender'])):

         // ...
         @foreach ($sender as $key => $value) 
           // ...
           @if (!empty($value)) 
               // ... 
           @elseif (is_numeric($start_if)) 
              // ... 
           @else 
              // ... 
           @endif
         @endforeach

         // Aquí usa @php
         @php 
            $layout = preg_replace("/\[\[IF-(.*?)\]\]([\s\S]*?)\[\[ENDIF-(.*?)\]\]/u", "", $layout);
         @endphp
         @if (!empty($_REQUEST['download'])) 
          // ...
         @endif
         @if (!empty($_REQUEST['Guardar'])) {
          // ...
         @endif

         echo $layout; <-- Borra esta linea o usa blade o la consola de tu navegador

      @else //aquí quita los dos puntos (:)        
         // ...

      @endif
   @endif

@else
    // ...
@endif

@endsection

Finally, we recommend you use tabulations and read the documentation, the idea is that the framework facilitates your work and does it, you just have to read a little more. Greetings

    
answered by 09.07.2018 в 17:55