OiO.lk Blog PHP I can't pass data to the component in Laravel
PHP

I can't pass data to the component in Laravel


I’m trying to pass data to the components using directly to the Blade component (using @props).

As a first step I put the following code in notification.blade.php:

@props([
    'type' => 'info',
    'message'
])

<div class="alert alert-{{ $type }} notification">
    {{ $message }}
</div>

Now in the test.blade.php view I put the following code (:type and :message are data passed to the component)

<x-notification type="success" message="Success! Your changes have been saved" />

<x-notification type="warning" message="Error! Something went wrong" />

<x-notification :type="$type" :message="$message" />

I get the following error:

Undefined variable $message

Can someone help me please?



You need to sign in to view this answers

Exit mobile version