Closed. This question is
my code
$categoryDetails = $category->categoryDetails;
$categoryDetailsInput = $request['c_details'];
$minPrice = $category->buyer_fee (($category->buyer_fee * auth()->user()->levell->product_charge)/100);
if (($request->regular_price < $minPrice) || ($request->extended_price < $minPrice)) {
$notify[] = ['error', 'Minimum price is '.$minPrice];
return back()->withNotify($notify);
}
if (count($categoryDetailsInput) != count($categoryDetails)) {
$notify[] = ['error', 'Something goes wrong. Please contact with developer'];
return back()->withNotify($notify);
}
CodePudding user response:
you caught in that error because when you received data from database if You request single object then that will be an object data type not array data type.
So, use this syntax for the query resulted variable
count(array($categoryDetails))
CodePudding user response:
this happens because count()
is only used for arrays,
Before this line
if (count($categoryDetailsInput) != count($categoryDetails)) {
use and check whether both are arrays
dump(is_array($categoryDetailsInput));
dd(is_array($categoryDetails));