I tried this using a variable,
$id = 3;
DB::transaction(function() {
DB::table('users')->where('id','=',$id)->get();
});
It throws an error:
Undefined variable: id
I also tried to place to $id as a parameter like this:
$id = 3;
DB::transaction(function($id) {
DB::table('users')->where('id', '=', $id)->get();
});
Still, an error:
Object of class Illuminate\Database\MySqlConnection could not be converted to string
Have I done anything wrong?