How to utilize components in Laravel 6.x.?

Viewed 91

I want to create a component; however, it does not work, and I get a 500 Internal Server Error.

@component('components.pulldown')
@endcomponent

As a workaround, I used the Blade directive @extend instead. However, it only displays the upper side of the page. Can someone please advise?

@foreach ($users as $user)
    <tr>
        <td>
            {{ $user->id }}
        </td>
        <td>
            {{ $user->name }}
        </td>
        @if($user->country)
            <td>
                {{ $user->country }}
            </td>
        @else
            <td>
                Select @extends('components.pulldown')
            </td>
        @endif
    </tr>
@endforeach

<select name="countries">
    <option value="US">US</option>
    <option value="UK">UK</option>
    <option value="EU">EU</option>
    <option value="JP">Japan</option>
</select>
1 Answers

Instead of @extend use @include. This will resolve the issue. For more details about laravel components visit this link: here

Related