We are trying use bootstrap components for our fresh laravel project.
GitHub: https://github.com/appstract/laravel-bootstrap-components
we have following code in blade. but it doesn't work and have error.
blade codes:
@extends('layouts.app')
@section('page-title','Welcome')
@section('content')
@component('bootstrap::alert', ['type' => 'danger'])
A simple alert of danger type
@endcomponent
@stop
error:
ErrorException (E_ERROR) Undefined variable: class (View: B:\xampp\htdocs\me2weesources\views\vendor\bootstrap\alert.blade.php) (View: B:\xampp\htdocs\me2weesources\views\vendor\bootstrap\alert.blade.php)
what we have to do to fix it?
It seems alert.blade.php contains the following snippet:
{{ $class or '' }}
The latest version of Laravel no longer supports or
between curly brackets in blade. These have been replaced by PHP 7's null coalesce operator.
So it should now be like this:
{{ $class ?? '' }}
More info: https://laravel-news.com/blade-templates-null-coalesce-operator