Hi all, As the title tells, how can i create an Utility Class where the functions are visible from my controller? what's The correct way to do it?
thanks
There are several methods you could use. One is to create a Facade and access your utility class that way, however my preferred method is to have the class injected via my class's __construct()
method, like so:
Class MyClass
{
protected $utilityClass;
public function __construct( UtilityClass $utilityClass )
{
$this->utilityClass = $utilityClass;
}
}
thanks, in which directory it will be positioned?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community