eloquent count code example

Example 1: get count laravel

$count = Model::where('status','=','1')->count();

Example 2: laravel eloquent remove from db

public function destroy($id){

  $res=User::find($id)->delete();
  if ($res){
    $data=[
    'status'=>'1',
    'msg'=>'success'
  ];
  }else{
    $data=[
    'status'=>'0',
    'msg'=>'fail'
  ];
  return response()->json($data);

Example 3: check count in laravel

$wordlist = Wordlist::where('id', '<=', $correctedComparisons)->get();
$wordCount = $wordlist->count();

Example 4: {{count laravel

{{ count($threads) }}

Example 5: laravel update first

Model::where(['x' => 1, 'y' => 2])->first()->update([...]);