Ap3twe
4 months ago
114
7
Laravel

Sending mail to Project Owner

Posted 4 months ago by Ap3twe

Admin updates a project that belongs to a user then I want to trigger mail notification to the user and also me. $request-user() is for the admin. How do I pass the email of the project owner? I have tried some methods but I can't get it right.

Example 1. I get "Trying to get property 'email' of non-object "

          $owner =  $project->user_id->email;
          Mail::to([$request->user(), $owner])->send(new ProjectUpdated($project));

Example 2.

          $owner =  Project::where('user_id', auth()->id())->findOrFail('email');
         Mail::to([$request->user(), $owner])->send(new ProjectUpdated($project));

Please sign in or create an account to participate in this conversation.