I have a class public static method that grabs some database information and returns a integer. In a controller i can call that method just fine. How do i call that static method in a blade template?
For example:
@foreach ($tasks as $task)
{{Task::percentComplete($task->id)}}%<br />
@endforeach
Thank you
Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates.
You could either
A- Make it a Facade : http://laravel.com/docs/facades
B- Move it into a helper/library : https://stackoverflow.com/a/13481218/2446119
I personally think that helpers and libraries are much easier and quicker to code, but facades are cleaner.
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