I have a laravel project with CalendarService and I inject this service into my controller. In the constructor, I am doing something like this:
CalendarService.php
private $timelogs;
public function __construct()
{
$this->currentRoute = URL::to( '/' ) . "/home";
$this->timelogs = Auth::user()->timelogs()->get();
$this->currentDay = 0;
}
HomeController.php
protected $calenderService;
public function __construct
(
CalendarService $calendarService
)
{
$this->calenderService = $calendarService;
}
And I get this error
Calling the member function timelogs () at zero
About this line of code:
Auth::user()->timelogs()->get();
I used use Illuminate\Support\Facades\Auth;in my service
What's going on here?
source
share