I have a simple database query to put out some stuff from database like example:
$user->HeadHits = DB::table('csstats AS cs')
->where('cs.steamid', '=', $user->steam_id)
->select("cs.h_1")
->first()->h_1;
And blade:
@if ($user->HeadHits == 0)
0%
@else
<?php echo number_format($user->HeadHits / $user->AllHits * 100,2); ?>%
@endif
But i'm getting error if user steam_id not find in database:
Trying to get property of non-object
Any suggest? Thanks
$useran eloquent model? If so, do you also have a model set up forcsstats?csstate?