Components & Slots in Blade Template in Laravel 6 Example
1. Reference URL:https://learnku.com/docs/laravel/6.x/blade/5147#20f1dd. Blade Template – Components & Slots
2. First write a reusable “alert” component, we want to reuse it in the application, create a new file: /resources/views/alert.blade.php
{{ $title }}
{{ $slot }}
3. Configure the route in /routes/web.php
Route::get('component', function () {
return view('component');
});
4. Create a new template file: /resources/views/component.blade.php
@component('alert')
@slot('title')
Forbidden
@endslot
You are not allowed to access this resource!
@endcomponent
5. Open the URL: view-source:http://laravel-theme-demo.local/component. View the source code. in line with expectations. as shown in Figure 1
Forbidden
You are not allowed to access this resource!
