What do you need to inject? If you want to print variable do it this way:
{{ $variable }}
heihachi88 said:
What do you need to inject? If you want to print variable do it this way:
{{ $variable }}
Same question. But why you have to do so, using View::composer() & View::creator() may be a good idea.
I was really hoping to push a closure into the blade, but I suspect that the PHP in a blade is only parsed/executed once. I think that composer and creator may do what I want, so I'll have a look at them.
Thanks for your help!
Hi
I inject PHP into some of my blade views out of convenience because it is easier to write than go through the controller.
You can do something like this
<? require_once("app/config/db.php"); if (isset($suburb) && isset($postcode)){ $st = DBase::singleton() ->prepare( 'select `council`,`suburb` ' . 'from `suburb_near` ' . 'where `suburb` like :id and `postcode` like :pid'); $st->bindParam(':id', $suburb, PDO::PARAM_STR); $st->bindParam(':pid', $postcode, PDO::PARAM_STR); if ($st->execute()) { while ($row = $st->fetch(PDO::FETCH_OBJ)) { $council = $row->council; echo "{$suburb} is in the {$council}. "; echo "<br><a href='//seek.estate{$url}?council={$council}'>Click Here are all Properties in {$council}</a>"; } } } ?>Which is what I'm using in my website https://seek.estate/buy to find all the properties in a given area.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community