This is a public shared error.
PHP
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'category_id' in 'where clause'
select count(*) as aggregate from `products` where (`category_id` = 1)
$data['digital_item']=Product::whereIn('id', function($query){
$query->select('product_id')->from('product_information')->where('digital_product', '1');
})->count();
$data['not_digital_item']=Product::whereIn('id', function($query){
$query->select('product_id')->from('product_information')->where('digital_product', '0');
})->count();
$data['total_products']=Product::count();
$products = Product::orderBy('id', 'desc')
->where( function($query) use($request){
return $request->status_id ?
$query->from('products')->where('status',$request->status_id) : '';})
->where( function($query) use($request){
return $request->category_id ?
$query->from('product_categories')->where('category_id',$request->category_id) : '';})
->paginate(30);
$selected_id = [];
$selected_id['status_id'] = $request->status_id;
$selected_id['category_id'] = $request->category_id;
return view('dashboard.products.index', compact('products', 'selected_id'), $data);
}
public function create()
{
$data['productCapacity'] = DB::table('config_settings')->where('_key','productCapacity')->first();
$data['total_products']=Product::count();
$data['categories'] = DB::table('categories')->get();
$data['colors'] = DB::table('colors')->get();
App
Request
http://127.0.0.1/dashboard/products?_token=ZqnCqwlAHE0R4vhn241dhPowpy3CthNiTlqdUwtu&category_id=1
GET
curl "http://127.0.0.1/dashboard/products" \
-X GET \
-H 'host: 127.0.0.1:8000' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'cookie: XSRF-TOKEN=eyJpdiI6IlkxSm56SGxDeGRjQTBxVm5iamdjRkE9PSIsInZhbHVlIjoidGlBajVjVEc1ZHB1NElyYW9TM0FLSmlPSG9xeHMzc2Z4ejhWZFRnOWw5dzdKM2t2MVkyTDkzRit6MnYzczZzREl6VnJDUFdKOVhTZGxmYkJ5VWl0TStzOXEwSERvbSt0ckJ4RllXTDhyL2hNSDdIRVNTeXpYUDlJL3JlYmEwRVYiLCJtYWMiOiIzOGE1Y2ZlMjMzNzM2MTVlNWIzODBmNTk1NDg2ZGE0ZGZkYWIwZjNhNjU4NzM4MmU5MTk1YWFmZTUzM2M3YTE2In0%3D; laravel_session=eyJpdiI6IjZoY2dERWM3R1F2OVVucjVOUUcrZ0E9PSIsInZhbHVlIjoiQ0xmSUE4cWFucFZJWjBRWlBLTlJsU2tRbENJNXg1eGhvZWRRQlpoV1RvR2U1UklCQUFEZ3BQdVpuOFRyeU5DemwrTkNaelpTMGpvc3lzZzhSR1pFc002SDl4UWlsZjdVOEtmTmhsVmtQeTFuU01WTGFKN3RtY0ppNC9LVnRpOWUiLCJtYWMiOiJlMDhjYWE4MjkwODE1OThmNTZkNjQzYzY3NDA0ZGZjNjQ5MjE5Y2VmYjFjYjdmZTQyODNiZmYzZTg4ZTU5YzhmIn0%3D' \
-H 'referer: http://127.0.0.1:8000/dashboard/products' \
-H 'sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"' \
-H 'connection: keep-alive' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36' \
-H 'cache-control: max-age=0' \
-H 'sec-fetch-dest: document' \
-H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-fetch-user: ?1' \
-H 'accept-encoding: gzip, deflate, br' \
-H 'accept-language: en,en-US;q=0.9,ar;q=0.8' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'upgrade-insecure-requests: 1' \
-F '_token=ZqnCqwlAHE0R4vhn241dhPowpy3CthNiTlqdUwtu' -F 'category_id=1'
Headers
- host
127.0.0.1:8000
- accept
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
- cookie
XSRF-TOKEN=eyJpdiI6IlkxSm56SGxDeGRjQTBxVm5iamdjRkE9PSIsInZhbHVlIjoidGlBajVjVEc1ZHB1NElyYW9TM0FLSmlPSG9xeHMzc2Z4ejhWZFRnOWw5dzdKM2t2MVkyTDkzRit6MnYzczZzREl6VnJDUFdKOVhTZGxmYkJ5VWl0TStzOXEwSERvbSt0ckJ4RllXTDhyL2hNSDdIRVNTeXpYUDlJL3JlYmEwRVYiLCJtYWMiOiIzOGE1Y2ZlMjMzNzM2MTVlNWIzODBmNTk1NDg2ZGE0ZGZkYWIwZjNhNjU4NzM4MmU5MTk1YWFmZTUzM2M3YTE2In0%3D; laravel_session=eyJpdiI6IjZoY2dERWM3R1F2OVVucjVOUUcrZ0E9PSIsInZhbHVlIjoiQ0xmSUE4cWFucFZJWjBRWlBLTlJsU2tRbENJNXg1eGhvZWRRQlpoV1RvR2U1UklCQUFEZ3BQdVpuOFRyeU5DemwrTkNaelpTMGpvc3lzZzhSR1pFc002SDl4UWlsZjdVOEtmTmhsVmtQeTFuU01WTGFKN3RtY0ppNC9LVnRpOWUiLCJtYWMiOiJlMDhjYWE4MjkwODE1OThmNTZkNjQzYzY3NDA0ZGZjNjQ5MjE5Y2VmYjFjYjdmZTQyODNiZmYzZTg4ZTU5YzhmIn0%3D
- referer
http://127.0.0.1:8000/dashboard/products
- sec-ch-ua
"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
- connection
keep-alive
- user-agent
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
- cache-control
max-age=0
- sec-fetch-dest
document
- sec-fetch-mode
navigate
- sec-fetch-site
same-origin
- sec-fetch-user
?1
- accept-encoding
gzip, deflate, br
- accept-language
en,en-US;q=0.9,ar;q=0.8
- sec-ch-ua-mobile
?0
- upgrade-insecure-requests
1
Session
- url
{ "intended": "http://127.0.0.1:8000/dashboard/products" }
- _flash
{ "new": [], "old": [] }
- _token
ZqnCqwlAHE0R4vhn241dhPowpy3CthNiTlqdUwtu
- locale
ar
- _previous
{ "url": "http://127.0.0.1:8000/dashboard/products?_token=ZqnCqwlAHE0R4vhn241dhPowpy3CthNiTlqdUwtu&category_id=1" }
- password_hash_web
$2y$10$pzS8mJt1ij4Tiiql4.oxDeoJW8SjuX0MT/bQ2pYCAKTIgi5Jml/Fi
- login_web_59ba36addc2b2f9401580f014c7f58ea4e30989d
1
Context
User
admin@gmail.com
ID: 1
{
"id": 1,
"name": "Admin Demo",
"rule": "admin",
"email": "admin@gmail.com",
"image": null,
"phone": "0555555555",
"status": 1,
"created_at": "2020-01-01T09:00:00.000000Z",
"updated_at": "2021-04-14T15:23:26.000000Z",
"verify_code": null,
"store_credit": 0,
"email_verified": 1,
"phone_verified": 1,
"last_login_time": "2021-04-14 18:23:26"
}
7:39:27 AM
3.490048ms
mysql
select * from `users` where `id` = 1 limit 1
7:39:33 AM
0.600064ms
mysql
select * from `config_settings` where `_key` = productCapacity limit 1
7:39:34 AM
0.570112ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_stocks` where `quantity` = 0)
7:39:35 AM
0.489984ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_stocks` where `quantity` between 1 and 5)
7:39:36 AM
0.420096ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_stocks` where `quantity` >= 6)
7:39:36 AM
0.36992ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_prices` where `price` = 0)
7:39:37 AM
0.43008ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_prices` where `sale_price` >= 1)
7:39:37 AM
0.359936ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_information` where `digital_product` = 1)
7:39:38 AM
0.300032ms
mysql
select count(*) as aggregate from `products` where `id` in (select `product_id` from `product_information` where `digital_product` = 0)
7:39:38 AM
0.310016ms
mysql
select count(*) as aggregate from `products`