I am using Laravel. I knew we can write constructor dependency injection as below code. I am wondering how it is working? I mean how constructor get $post and $user model objects? How it is injected?
/**
* Inject the models.
* @param Post $post
* @param User $user
*/
public function __construct(Post $post, User $user)
{
parent::__construct();
$this->post = $post;
$this->user = $user;
}
Please explain me. Thanks.