select find() in laravel 7 code example
Example 1: laravel update from query
$affected = DB::table('users')
->where('id', 1)
->update(['votes' => 1]);
Example 2: laravel where
$users = DB::table('users')
->whereDate('created_at', '2016-12-31')
->get();
Example 3: when in larevel
$role = $request->input('role');
$users = DB::table('users')
->when($role, function ($query, $role) {
return $query->where('role_id', $role);
})
->get();