Reputation: 9692
I have defined a variable like $alarm
in my php page. It returns like;
In my page I try to access GradeName , So calling like; (I want to extract all details from that returned alarm details)
<div class=...
$alarm[0]['GradeName']
</div>
But Im getting
Trying to get property of non-object (View: /app/resources/views/alarms/ack.blade.php)
in c593810096345df8c818851d1e61ae4bc523a3d4.php (line 43)
at CompilerEngine->handleViewException(object(ErrorException), 0)
in PhpEngine.php (line 44)
at PhpEngine->evaluatePath('/app/storage/framework/views/c593810096345df8c818851d1e61ae4bc523a3d4.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'alarm' => object(Alarm), 'yfSessionId' => '2OxcAqWMEGxuiYzjm2ox7Wmih2BP6HfrWdMXILmcdRjVsmiZSwBEhA=='))
in CompilerEngine.php (line 59)
What I'm doing wrong here?
{"AlarmId":173358,"MessageNotificationId":"105933",
"CompanyId":"33",
"CompanyCode":"EURO",
"AlertTypeId":"23",
"AlertId":"4314893",
"SiteCode":"20167822",
"SiteName":"Trafford Centre Service Station",
"TankNumber":null,
"DispenserNumbedr":null,
"HoseNumber":null,
"GradeId":null,
"GradeName":null}
If I do like this in my php class;
public function(){
**echo "<font color='red'><b>$alarm->CompanyCode</font></b><br>";** //---------->I see this
return view('alarms.ack', ['alarm' => $alarm, 'yfSessionId' => $yfSessionId]);
}
In my view if I access like I get non-object issue;
<div class="form-group">
<label class="col-md-4 control-label">Volume</label>
<div class="col-md-6 control-label-text-left">
{{ $alarm->AlarmVolume }}
</div>
</div>
Upvotes: 0
Views: 54
Reputation: 2945
in errors it says 'alarm' => object(Alarm)
please try to access, your GradeName
property like this : $alarm->GradeName
Upvotes: 1