I have a user model that accepts an instance of the UserMailer class in its constructor, but I get this error
Argument 1 passed to User::__construct() must be an instance of TrainerCompare\Mailers\UserMailer, none given, called in /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 631 and defined
I understand the error, but I canβt understand what I did wrong, but I am not very good at class names and class classes and vs psr0. I remember how to use the dump-autoload linker, so this is not the case.
folder structure
composer.json app/ models/ User.php TrainerCompare/ Mailers/ Mailer.php UserMailer.php Services/ Validation/
startup section composer.json. The psr-0 section is when I added the validation service, which you can see in TrainerCompare /, and these classes work fine. I added the / TrainerCompare / Mailers application to classmap for the tutorial that I am following to load mailbox classes
"autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php", "app/tests/helpers", "app/TrainerCompare/Mailers" ], "psr-0":{ "TrainerCompare": "app/" } }
User.php
<?php use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; use TrainerCompare\Mailers\UserMailer as Mailer; class User extends BaseModel implements UserInterface, RemindableInterface { protected $mailer; public function __construct(Mailer $mailer) { $this->mailer = $mailer; } }
Mailer.php
<?php namespace TrainerCompare\Mailers; use Mail; abstract class Mailer { public function __construct() {
UserMailer.php
<?php namespace TrainerCompare\Mailers; use User; class UserMailer extends Mailer { public function __construct() {