Well, I have a problem, mostly I'm cleaning up my code.
$general_controller = new GeneralController();
$user_data = $general_controller->userData();
I am calling a method from another class, this is the code I use. First I call a new instance of the class and then in that class I point to the motodo I want. I would like to know if there is any way to do it directly in a single line and not in two.
if you say that
Then nothing prevents you from doing:
Now, take into account that if your function does not provide you with anything else like the object it represents, then consider making the method you invoke static. In which case it would be like this:
As a note, clarify that your question has nothing to do with Laravel, but it is something that you will see a lot there. In fact, if you analyze its controllers, you will see that it implements static methods by default, although in the future it implies a high coupling. But that is another subject...