0
votes

This error is occurring even though I am passing and retrieving the object properly. The error is in $dat. I am using it here :

                       <tr>
                            <th scope="row">{{$data->id}}</th>
                            <td>{{$dat->created_at}}</td>
                        </tr>


    




 public function view_giftcard_data($id){
        return view('admin.view_giftcard_data' , ['data' => Giftcards::where('id' , $id)->first() , 'dat' => Giftcard_codes::where('giftcard_id' , $id)]);
    }

The name of table is correct.

1
Is this a typo <td>{{$dat->created_at}}</td>? You're missing an a on $dat.DigitalDrifter
No I am returning variables data and dat from the function, I know the names are messed up but are for testing xd.M. Hasnat Raza

1 Answers

1
votes

its because still a builder not a model, you need to take the model for example first to finish the query, like this:

public function view_giftcard_data($id){
        return view('admin.view_giftcard_data' , ['data' => Giftcards::where('id' , $id)->first() , 'dat' => Giftcard_codes::where('giftcard_id' , $id)->first()]);
    }