I get the following error when trying to send an email with laravel
Type error: Argument 1 passed to App \ Mail \ AnalystMonth :: __ construct () must be an instance of App \ Mail \ DataUser, instance of Illuminate \ Database \ Eloquent \ Collection given, called in C: \ wamp \ www \ intranet \ intranet \ app \ Http \ Controllers \ AnalystController.php online 37
My Mailer class
class AnalystMonth extends Mailable
{
use Queueable, SerializesModels;
public $dataUser;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(DataUser $dataUser)
{
$this->dataUser = $dataUser;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('mails.analystMonth');
}
}
My controller function to send the email
public function choiceAnalyst(Request $request){
$file = $request->file('document');
$userSelect = $request->input('user');
$data = User::where('id', '=', $userSelect)->get();
\Mail::to('[email protected]')->send(new AnalystMonth($data));
}
How can I solve the error ?, I know that the error is in the part that I want to load the data to see them, because if I remove those lines of code, the mail arrives without problem