Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel 5.0 Including Sub View Into Another View

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 448
    Comment on it

    Many times we need some sections of HTML which need to be incorporated in many views and just to reduce redundancy we create separate views for it.


    An example to accomplish that is stated below:-

    Including other views in other view syntax :-

    @include('partials.alerts.errors')
    @include('partials.alerts.success')
    

    Create a view as errors inside /resources/views/partials/alerts/errors.blade.php

    @if($errors->any())
    <div class="alert alert-danger">
        <strong>Whoops!</strong> There were some problems with your input.<br><br>
        <ul>
            @foreach($errors-&gt;all() as $error)
            <li>{{$error}}</li>
            @endforeach
        </ul>   
    </div>
    @endif
    

    Create a view as success inside /resources/views/partials/alerts/success.blade.php

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

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: