dimanche 29 avril 2018

How can get a matched data from another table using Eloquent?

I would like to display product number, product name and procut detail.

I can display "product number" as below code that is ($pn) I would like to bring "product name" and "product detatil" data which only mache to ($pnum) below foreach loop.

Another table name is "pn_list". table A $pn and table B $pnum should be maches then displya table B's product name is $pname product detail is $pdetail shows up.

blade file (pn is product number)

@foreach  ($pns as $pnx) 
,
@endforeach   

Controller

 public function countpn(Request $request)
    {   $pns = Tablea::select('pn', DB::raw('COUNT(pn) count'))
            ->groupBy('pn')
            ->get();

    return view('pn.index')->with('pns',$pns);
    }

Sorry I have no idea how to combine 2nd table and matching rule so I didn'T make code.



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

Aucun commentaire:

Enregistrer un commentaire