Muhammad Asfund Muhammad Asfund - 1 year ago 185
PHP Question

How to call/use Controller method in its View using Laravel 5.0?

I need to use my controller function in its own view.

I have tried Facade but failed.

Answer Source

You want to use a function defined in a Controller in one of the views it is calling?

If that's your question you can do following, (I am assuming the function is public static function returning some string). In your blade view file you can just call the function using the full name space path.


(There are ways in blade to import a class using use statement)

It is not recommended to call functions defined in controller like this (its against MVC), you can define them in the Model or create a separate Helper class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download