I have a users controller and i want to trigger my constructor for the dependency injection works but when i request to UsersController@index to show all paginated users the userRepository property returns null meaning the constructor did not initialized..
protected $userRepository;
/**
* @param UserRepository $userRepository
*/
function _construct(UserRepository $userRepository)
{
dd('e');
$this->userRepository = $userRepository;
}
/**
* Display a list of registered users.
*
* @return Response
*/
public function index()
{
dd($this->userRepository);
$users = $this->userRepository->getPaginated();
return View::make('users.index')->withUsers($users);
}
The magic constructor method has a double underscore __construct()
WTF!! i didn't see that... thanks man..
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community