Make use of the value
method on the query builder to execute a more efficient query when you only need to retrieve a single column.
1// Before (fetches all columns on the row)2Statistic::where('user_id', 4)->first()->post_count;3 4// After (fetches only `post_count`)5Statistic::where('user_id', 4)->value('post_count');
Tip given by @mattkingshott