0

How to display variable ['attributes'] & ['products'] separately in blade

$data = [];

$data ['attributes'] = Attribute::active()->whereNull('option_id')->get();
$data ['products'] = Product::orderBy('id', 'DESC')->get();

return view('dashboard.productOption.edit', compact('prOption','data'));
steven7mwesigwa
  • 5,701
  • 3
  • 20
  • 34
  • I advise you check out the Blade documentation to see how to display data in a Blade view: https://laravel.com/docs/8.x/blade#displaying-data – Thelonias Dec 15 '21 at 19:54
  • 1
    Does this answer your question? [How to pass data to view in Laravel?](https://stackoverflow.com/questions/18341792/how-to-pass-data-to-view-in-laravel) – steven7mwesigwa Dec 15 '21 at 20:09

1 Answers1

0

You call them as you would any other associative array element:

@foreach ($data['attributes'] as $attribute)
  <p>{{ $attribute }}</p>
@endforeach

The same applies for accessing products.

Peppermintology
  • 9,343
  • 3
  • 27
  • 51