count parameter must be an array or an object that implements countable in laravel

0 votes


Have shared my code below:

protected function credentials(Request $request) 
{ 

    $admin=admin::where('email',$request->email)->first(); 
    if(count($admin)) 
    { 

            if($admin->status==0){ 
                return ['email'=>'inactive','password'=>'You are not an active person, Please contact to admin']; 
                  } 

                else{ 
                        return ['email'=>$request->email,'password'=>$request->password,'status'=>1]; 
          } 
    } 
  return $request->only($this->username(), 'password'); 
}

When i run the code this error is displayed as:

"count(): Parameter must be an array or an object that implements Countable"

Feb 10, 2022 in Others by Soham
• 9,710 points
6,675 views

1 answer to this question.

0 votes

You will have to make one change to the lines of code which has been my solution and has worked for me. Please refer to the line mentioned below:-

count(array($variable));

answered Feb 10, 2022 by Rahul
• 9,680 points

Related Questions In Others

0 votes
1 answer

Highlight cells in an Excel column if the value can be found in an array

Try this: =COUNTIFS(B:E,$A1) READ MORE

answered Feb 24, 2023 in Others by narikkadan
• 63,600 points
1,392 views
0 votes
1 answer

Reducing sequences in an array of strings

I've written a C# app to solves ...READ MORE

answered Nov 2, 2018 in Others by DataKing99
• 8,250 points
910 views
0 votes
1 answer

How can you create an object in JavaScript?

JavaScript supports Object concept very well. You can create ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
584 views
0 votes
1 answer

How to exclude specific folders every time I run 'eb deploy' using AWS EB CLI

If there is not .ebignore file it ...READ MORE

answered Oct 24, 2018 in AWS by Priyaj
• 58,020 points
2,089 views
0 votes
0 answers

Self Created Laravel Link Not Working

I installed laravel 6.0 through composer and ...READ MORE

Dec 3, 2019 in Others by anonymous
• 120 points
810 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,012 views
+1 vote
1 answer

ng is not recognized as an internal or external command

I solved this problem in accordance with ...READ MORE

answered Feb 11, 2022 in Others by Rahul
• 9,680 points
16,520 views
0 votes
1 answer

ERROR:'keytool' is not recognized as an internal or external command, operable program or batch file

Check if the directory and the keytool ...READ MORE

answered Feb 18, 2022 in Others by Rahul
• 9,680 points
8,736 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP