I want to instantiate a singleton class in Laravel:
namespace App\Services;
use Illuminate\Support\Facades\Auth;
class UserService{
//code
$friendRequestService = $this->app->make(FriendRequestService::class);;
I get this error:
Undefined property: App\Services\UserService::$app
CodePudding user response:
Use laravel helper to instantiate a class from the Container:
app()->make();