jeudi 23 juin 2016

L5 - Error : Trying to get property of non-object (Weird Case)

can you guys show me what's wrong with my code? here's the code

$datax = \App\AccountsScore::where('account_id', $account_id)->where('score_id', $score->id)->first();
$datav = \App\AccountsScoreHistory::where('account_score_id', $datax->id)->get();

i got error on $datav 's line because of Trying to get property of non-object. however, below is the result when i print $datax or $datax->id.

$datax

App\AccountsScore Object ( [connection:protected] => riskserver [table:protected] => accounts_score [primaryKey:protected] => id [keyType:protected] => int [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 24467 [account_id] => 114 [score_id] => 14 [value] => 8 ) [original:protected] => Array ( [id] => 24467 [account_id] => 114 [score_id] => 14 [value] => 8 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => ) 

$datax->id

24467

So frustating about this code, any help appreciated.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/28TPnvf
via IFTTT

Aucun commentaire:

Enregistrer un commentaire