This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
Open
Description
I have a component dashboard-card.blade.php
which is structured this way:
<div class="mb-4 col-sm-6 col-lg-4">
<div class="card-small card">
<div class="border-bottom card-header">
<h6 class="m-0">{{$title}}</h6>
</div>
<div class="p-0 card-body">
<div class="list-group-small list-group list-group-flush">
{{$slot}}
</div>
</div>
<div class="border-top card-footer">
<div class="row">
<div class="text-right view-report col">
<a href="{{$link}}" class="" target="_self">{{$goto}} →</a>
</div>
</div>
</div>
</div>
</div>
This is rendered in my blade view:
<x-dashboard-card title="Reports" goto="Vai ai Report" link="reports/index/weekly">
<div class="d-flex px-3 list-group-item">
<span class="text-semibold text-danger">Report da compilare</span>
<span class="ml-auto text-right text-semibold text-danger">{{$count}}</span>
</div>
</x-dashboard-card>
In this blade view I placed a {{$count}}
variable within the slot and I'm trying to set it from the DashboardCard.php
class:
public $title;
public $count = 0;
public $link;
public $goto;
public function __construct($title, $link, $goto)
{
$this->title = $title;
$this->link = $link;
$this->goto = $goto;
}
I was expecting to have the count show 0
but it actually returns an error Undefined variable: slot (View: /resources/views/pages/dashboard.blade.php)
As far as I understand there is no way to pass data from the blade component to the inner slot, wouldn't it be useful?
Metadata
Assignees
Labels
No labels