What does the make() method do in Laravel?

Share:
Laravel's make method is used to create an instance of a class or interface.While creating an instance with make method Laravel will automatically inject all dependencies of class that is defined in it's constructor. E.g. an instance of the Mailer class would be automatically injected in below code.
namespace App\Services;

use \Illuminate\Mail\Mailer;

class MyService
{
    public function __construct(Mailer $mailer) {
        $this->mailer = new Mailer;
    }
}

No comments