I'm new to Laravel.
I wonder how I can avoid query to be chained.
$visitRecords = VisitRecord::whereDate('visited_at', '=', Carbon::today()->toDateString());
$knockBounce = $visitRecords->where("bounce_zone", "1")->get()->count();
$approachBounce = $visitRecords->where("bounce_zone", "2")->get()->count();
This is the code I wrote but this gives me the result I don't expect...
Result
select * from `visit_records` where date(`visited_at`) = '2017-05-12'
select * from `visit_records` where date(`visited_at`) = '2017-05-12' and `bounce_zone` = '1'
select * from `visit_records` where date(`visited_at`) = '2017-05-12' and `bounce_zone` = '1' and `bounce_zone` = '2'
I checked the query conducted and this is what I got.
What I expect...
select * from `visit_records` where date(`visited_at`) = '2017-05-12'
select * from `visit_records` where date(`visited_at`) = '2017-05-12' and `bounce_zone` = '1'
select * from `visit_records` where date(`visited_at`) = '2017-05-12' and `bounce_zone` = '2'
I want to conduct this query instead via Eloquent methods.