Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)

Cugurel picture Cugurel · May 7, 2018 · Viewed 16.8k times · Source

Hello dear i want to create a customer blade which provides users to import and export excel file. My customers_blade.php looks like this;

@extends('layouts.app')

@section('content')
<div class="panel-heading">Import and Export Data Into Excel File</div>

<div class="panel-body">
    {!! Form::open(array('route'=>'customer.import','method'=>'POST','files'=>'true')) !!}
    <div class="row">
        <div class="col-xs-10 col-sm-10 col-md-10">
            @if(Session::has('success'))
                <div class="alert alert-success">
                    {{Session :: get('message')}}
                </div>
                @if(Session::has(warning))
                <div class="alert alert-warning">
                    {{Session::get('message')}}
                </div>
                @endif
                <div class="form-group">
                    {!! Form::label('sample_file','Select File to Import:',['class'=>'col-md-3']) !!}
                    <div class="col-md-9">
                        {!! Form::file('customers',array('class'=>'form-control')) !!}
                        {!! $error->first('products','<p class="alert alert-danger">:message</p') !!}
                    </div>
                </div>
        </div>
        <div class="col-xs-2 col-sm-2 col-md-2 text-center">
            {!! Form::submit('Upload',['class'=>'btn btn-success']) !!}
        </div>
    </div>
    {!! Form::close() !!}
</div>
@endsection

But when i go to page this error occurs. How can i edit it. Can you please help me?

Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) (View: /home/vagrant/code/excel/resources/views/customers.blade.php)

Answer

Adnan Mumtaz picture Adnan Mumtaz · May 7, 2018

If you notice in your blade file you will find that you are missing @endif

                    @if(Session::has('success'))
                        <div class="alert alert-success">
                            {{Session :: get('message')}}
                        </div>
                    @endif

In the above section @if(Session::has('success')) this If was not ending anywhere.

@extends('layouts.app')

@section('content')
<div class="panel-heading">Import and Export Data Into Excel File</div>

<div class="panel-body">
    {!! 

    Form::open(array('route'=>'customer.import','method'=>'POST','files'=>'true')) !!}
        <div class="row">
            <div class="col-xs-10 col-sm-10 col-md-10">
                @if(Session::has('success'))
                    <div class="alert alert-success">
                        {{Session :: get('message')}}
                    </div>
                @endif  
                    @if(Session::has(warning))
                    <div class="alert alert-warning">
                        {{Session::get('message')}}
                    </div>
                    @endif
                    <div class="form-group">
                        {!! Form::label('sample_file','Select File to Import:',['class'=>'col-md-3']) !!}
                        <div class="col-md-9">
                            {!! Form::file('customers',array('class'=>'form-control')) !!}
                            {!! $error->first('products','<p class="alert alert-danger">:message</p') !!}
                        </div>
                    </div>
            </div>
            <div class="col-xs-2 col-sm-2 col-md-2 text-center">
                {!! Form::submit('Upload',['class'=>'btn btn-success']) !!}
            </div>
        </div>
        {!! Form::close() !!}
    </div>
    @endsection

Hope this helps