Issue
I have a route in my controller:
$emailRecipient = DB::select("
select
e.ID empID,
e.lname lname,
e.fname fname,
e.email email,
e.teamID,
e.agencyID,
e.accessProfileID,
e.accessTeams,
c.ID coID,
c.dDesc companyName
c.product,
c.modules
from
emailrecipient_tb er
left join employee_tb e on er.empID = e.ID
left join company_tb c on er.coID = c.ID
where
er.isDAR = 1 and
er.isActive = 1 and
c.isActive = 1
");
foreach ($emailRecipient as $rowRecipient) {
Mail::to($rowRecipient->email)->send(new DailyActivityReport2($rowRecipient));
}
and then in my DailyActivityReport2 class I have:
public $coID;
public $companyName;
public $product;
public $rEmpID;
public $rLname;
public $rFname;
public $rEmail;
public $rAccessTeamID;
public $rAccessAgencyID;
public $rAccessProfileID;
public $rAccessTeams;
public $rModules;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($rowRecipient)
{
$coID = $rowRecipient->coID;
$companyName = $rowRecipient->companyName;
$product = $rowRecipient->product;
$rEmpID = $rowRecipient->empID;
$rLname = $rowRecipient->lname;
$rFname = $rowRecipient->fname;
$rEmail = $rowRecipient->email;
$rAccessTeamID = $rowRecipient->teamID;
$rAccessAgencyID = $rowRecipient->agencyID;
$rAccessProfileID = $rowRecipient->accessProfileID;
$rAccessTeams = $rowRecipient->accessTeams;
$rModules = json_decode($rowRecipient->modules);
}
then I get an error:
Trying to get property 'coID' of non-object
the error is at:
$coID = $rowRecipient->coID;
The thing is if I try to use $rowRecipient->coID in the controller then the code works, only when I pass it in the class, then it no longer works...
Solution
I'm stupid, I didn't realize I hard-coded coID in the controller (for testing).
Answered By - jove0610
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.