Laravel — P9: Displaying Data in Blade Files

Dino Cajic
Geek Culture
Published in
4 min readDec 20, 2022

--

Dino Cajic on Display Data in Laravel Blade Files

We ended our previous article with a quick introduction into Blade. What we really wanted to achieve was introduce what Blade is, understand that there are Blade Directives, and figure out how to load our blade component once a specific route is hit.

In this article, we go deeper. We’re going to look at the following concepts:

  • Displaying Data
  • Displaying Unescaped Data

Displaying Data

We looked at passing data in the previous article, but we’re going to review it once more. Let’s create a route and pass data to our view.

Route::get('/my-favorite-car', function() {
return view('cars/car', [
'car' => 'Subaru WRX STi',
]);
});

The route /my-favorite-car will return a view /cars/car with our favorite car, in this instance the Subaru WRX STi (RIP STi). We need to create a cars/car.blade.php file.

You might have noticed that we’re only adding /cars/car instead of /cars/car.blade.php. We can do either or, but by…

--

--

Dino Cajic
Geek Culture

Author of An Illustrative Introduction to Algorithms. IT Leader with a B.S. in Computer Science, a minor in Biology, and a passion for learning.