php - Laravel - Undefined variable -
i'm having difficulty accessing variable, when it's there within table.
the error falls on line:
@if ($alert->alert_when == 1) @endif undefined variable: alert_when - error.
i dd() get() request prior accessing info in view , can see variable it's retrieving:
["alert_when"]=> string(1) "1" full dd print screen:
object(illuminate\database\eloquent\collection)#521 (1) { ["items":protected]=> array(2) { [0]=> object(criteria)#492 (20) { ["connection":protected]=> null ["table":protected]=> null ["primarykey":protected]=> string(2) "id" ["perpage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(15) { ["id"]=> string(2) "19" ["user_id"]=> string(2) "23" ["alert_when"]=> string(1) "1" ["created_at"]=> string(19) "0000-00-00 00:00:00" ["updated_at"]=> string(19) "0000-00-00 00:00:00" ["deleted_at"]=> null } i able access other info within row, , there isn't typos!
why error occurring? many in advance.
update
@if ($alert['alert_when'] == 1) returns right response without errors. why when can access $alert->name that?
do var_dump on variable. might referencing wrong. array. might have reference this:
$alert[0]->alert_when php laravel laravel-4
No comments:
Post a Comment