Skip to content
Advertisement

Laravel 8: How to style output at Models

I want to check if the status of users is Active or not. So in order to do this, I’ve added this piece of code to my Model User.php:

JavaScript

And at the Blade, I get result by saying:

JavaScript

But this will return this:

enter image description here

So the question is, how can I add some inline styles to the output of isActive() method ?

Advertisement

Answer

Generally you wouldn’t return markup from you model as you’re mixing concerns.

You would be ‘better’ using the value of your isActive() method in your blade view.

JavaScript

Your isActive() method would then just return a boolean value:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement