Ad
Using Subquery In Laravel To Find Count Of A Product Type In Same Tables With Multiple Where Conditions?
My question may not be clear, if you cannot understand please mention.
This is the complete structure of the table
Issue
- Get count of all applications for the user
- Remove first five applications from the select and get remaining count of it.
- In the above output's count need to filter type of product and get count for each product type.
Code Tried
$res_applications_count = CreateApplicationModel::where('rs_users_id', $sub_user_id)
//->skip($skip)
->take($limit)
->where([
['application_status', '!=', 'Not Submitted'],
['application_status', '!=', 'InProgress']
])
->whereBetween('created', [$sub_start_date, $sub_end_date])
->where('product_type', '=', "Residential")
->orderBy('created', 'DESC')
->get()
->count();
Need to get different product types count after discounting the allowed limit from overall count of the user's application. for ex 5 counts to be removed from 100 applications and check remaining 95 for product types.
Expected Ans
Total count - 100 Discount - 5 Remaining- 95
In Remaining get count of different types:
First type - 50 Second type - 20 Third Smooth - 25
Ad
Answer
Not sure if it is what you are looking for, but here is the user's applications count by product_type
and skipping first $skip
numbers of results:
$applications_count_by_product_type = CreateApplicationModel::where('rs_users_id', $sub_user_id)
->skip($skip)
->groupBy('product_type')
->count();
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad