dimanche 24 novembre 2019

I want to combine two tables by selecting the id entered by the user in Laravel

I want to retrieve the full name column in the user_detail table, by the user entering the selected id first in the Order table using Query Builder

in the order table it looks like this

 +"id": 1
  +"order_detail_id": 115
  +"user_id": 3
  +"status": "pending"
  +"updated_at": "2019-11-22 17:53:56"
  +"created_at": "2019-11-22 15:44:28"

in table user_detail it looks like this

 +"id": 3
  +"full_name": michael jackson
  +"address": "bla bla bla"
  +"updated_at": "2019-11-22 17:53:56"
  +"created_at": "2019-11-22 15:44:28"

I want if the user enters id 1 it will output like

            "id": 1,
            "order_detail_id": 115,
            "user_id": 3,
            "full_name": "michael jackson",
            "address" : "bla bla bla" 
            "status": "pending"

I tried with this code but an error still appears

 $cekclient = DB::table('order')
                                ->find($request->id)
                                ->join('user', 'user.id', '=', 'order.user_id')
                                ->select('order.*','user.name','user.address',)
                                ->get();

            dd($cekclient);


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/37zkmby
via IFTTT

Aucun commentaire:

Enregistrer un commentaire