Model: PlayerResult
protected $fillable = ['result']
result is string (varchar(191)) in db
Saved value in db is 'win' for example, when accessing through eloquent returned as true (boolean).
$var = PlayerResult::where('event_id', $event->id)->whereNotIn('player_id', [$player->id])->first();
In dd($var)'s attributes result is true, in original result is 'win'
I tried casting (in model) but still same...
So why is it returned as boolean? And how to fix it? Thanks
EDIT:
I thought @TimLewis solved the problem, but even I renamed column name to random name, there is still this weird problem.
When ->select('result AS exampleVariable') is added to query, result returns true, but exampleVariable returns 'win' - so I thought name of column is problem, but problem is not solved even I renamed that column...
$var = PlayerResult::where('event_id', $event->id)->whereNotIn('player_id', [$player->id])->first();->resultis a reserved word in Eloquent. If you add a->select("result AS exampleVariable")to your query then do add($var->exampleVariable);does it still returntrue?