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

Issue

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)

Solution

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

Answered By – Romantic Dev

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published