I've created a custom class inside the app/Helpers
folder.
I want to access it in views like Helper::someMethod()
. I tried to bind it in IoC
. But couldn't get it working. The following is my Helper class:
class ApplicationHelpers {
public function me() {
return "this is me!";
}
}
This is how I bind it in the AppServiceProvider class in register method.
$this->app->make('App\Helpers\ApplicationHelpers');
And this is how I want to access in view.
<div class="title m-b-md">
{{ ApplicationHelpers::me() }}
</div>
How can I achieve this?
If you do not register the class anywhere, you have to include the namespace. So it would look like this:
Or you can create an alias in your
config/app.php
and then call the class directly.