I am trying to create a Blade directive that will set a class on my table row depending on what gets passed in. The problem is that when I call it, the value of the variable is not being passed in - the literal string that I have between the parenthesis is.
In my view:
@row($inspection->inspection_disposition)
In the directive:
Blade::directive('row', function($data)
{
var_dump($data);
.
.
.
}
What I see in the dump is:
string(37) "($inspection->inspection_disposition)"
Shouldn't I see the value of that variable? That's what I want. What am I missing here?
MORE INFO:
I need to use the value of that variable in the directive, like this:
if($data == "hello")
{
return something
}
elseif($data == "goodbye")
{
return something else
}
This is a simplified example, but hopefully it will help to illustrate that I need to compare the value of the variable inside the directive, then determine what to do. Perhaps I need to use eval() ?
Blade directive should return a string that php will interprete, like this:
Blade::directive('row', function($data)
{
return "<?php var_dump($data); ?>";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With