-1

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

I have tried Facade but failed.

6
  • What you have tried so far ? Commented Jul 25, 2016 at 11:43
  • Check this : stackoverflow.com/a/22153332/2815635 Commented Jul 25, 2016 at 11:47
  • I have tried to create custom helper class. I have register it with provider and create its facade but not working. Commented Jul 25, 2016 at 11:48
  • Thanks for the link, but I have also tried this link but not working. Commented Jul 25, 2016 at 11:49
  • I have use App::make("PostsController")->get_social_plans_data(1); with my controller name and method, but not working, should I need to include any file or library? Commented Jul 25, 2016 at 11:50

1 Answer 1

0

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.

{{App\Http\Controllers\MyController::myFunction()}}

(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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.