getting undefined variable in my view
public function confirm()
{
$data = Transaction::select('number','total','package')->where('user_id','=',\Auth::user_id()->id)->first();
return view('user.package',compact('data'));
}
// My view
<center>
<h3 class="card-title"><b>You are about to buy {{$data->number}} package of {{$data->package}} for {{$data->total}}</b>
</h3>
</center>
$datais null for some reason? Becausefirst()returns null if it cannot find the row.$dataexactly contain?