laravel count code example
Example 1: get count laravel
$count = Model::where('status','=','1')->count();
Example 2: laravel not in query
DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();
Example 3: laravel update from query
$affected = DB::table('users')
->where('id', 1)
->update(['votes' => 1]);
Example 4: count in laravel'
$count = ModelName::where('id',$id)->count();
Example 5: parametre grouping laravel quert
DB::table('users')
->where('name', '=', 'John')
->where(function ($query) {
$query->where('votes', '>', 100)
->orWhere('title', '=', 'Admin');
})
->get();
Example 6: laravel sql query
use Illuminate\Support\Facades\DB;
$users = DB::select('select * from users');
foreach ($users as $user) {
echo $user->name;
}