Please format your code by adding ``` on the line before and after it
Sep 30, 2022
28
Level 1
Not working "Short Attribute Syntax" component in blade-template
Laravel v9.32.0 (PHP v8.1.5)
Someone could help me please why is the "Short Attribute Syntax" component in blade template is not working?
Why I can't use it even if I run composer update or installed again a laravel project?
App Component: app\View\Components\ShortAttributeSyntax.php
public $userId;
public $name;
public function __construct($userId, $name)
{
$this->userId = $userId;
$this->name = $name;
}
public function render()
{
return view('components.short-attribute-syntax');
}
Component: resources\views\components\short-attribute-syntax.blade.php
<div>
ID: {{ $userId }} <br>
Name: {{ $name }}
</div>
View: resources\views\app-short-attribute-syntax.blade.php
@php
$userId = 328;
$name = 'Adrian';
@endphp
<h3>Passing Data to component</h3>
{{-- Working --}}
<x-short-attribute-syntax :userId='$userId' :name='$name'/>
<h3>Short Attribute Syntax</h3>
{{-- Not working --}}
<x-short-attribute-syntax :$userId :$name />
Please or to participate in this conversation.