I have a view which has a component for showing house properties information.
<div class="row">
@foreach($matchs as $match)
@component('pages.processes.offerdemand.matchs.matchbox')
@endcomponent
@endforeach
</div>
In my Controller i'm returning a collection and each "matchbox" is created OK depending on the total elements of the collection.
class OfferdemandsmatchsController extends Controller
{
public function index ($id) {
$matchs = DB::table('offerdemandsmatchs')
->join('properties', 'offerdemandsmatchs.prop_id', '=', 'properties.prop_id')
->where('offerdemandsmatchs.offerdemand_id', '=', $id)
->select('properties.*', 'offerdemandsmatchs.created_at as matchcreated_at', 'offerdemandsmatchs.created_at as matchupdated_at',
'offerdemandsmatchs.like', 'offerdemandsmatchs.id as matchid')
->get();
return view('pages.processes.offerdemand.matchs.index', compact('matchs'));
}
}
The problem i'm facing is that I want to pass variable $match to each box, it looks like components only accept an array and not a collection.
<div class="row">
@foreach($matchs as $match)
@component('pages.processes.offerdemand.matchs.matchbox', $match)
@endcomponent
@endforeach
</div>
Facade\Ignition\Exceptions\ViewException
Argument 2 passed to Illuminate\View\Factory::startComponent() must be of the type array, object given, called in C:\Desarrollo\laragon\www\kw-plataforma\storage\framework\views\60fac8943d076d952347a84172f358cd1ee65f54.php on line 39 (
How can I pass the data to the component box?
Regards
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire