mercredi 27 décembre 2017

How to join a database from another database laravel

So I have this sub-window created and I want to put customer details.

At first, opening the sub-window(without using the search boxes) it returns data, but the data from another database cannot be shown.

Now when I use the search box, it now gives me error of: undefined variable paymentgroup.

I suppose my query is wrong but I don't know how to fix.

Here is my code:

public function index_sub_form(Request $request)
    {
        $keyword = $request->all();
        $perPage = 25;

        if($keyword) {
            $paymentgroup = TPaymentGroup::select('t_payment_group.id', 
                't_payment_group.payment_group_name', 
                DB::raw('clotho_mercurop_eccube.getfullAdd(eccube.customer_id) as getAdd'), 
                't_payment_group.main_customer_id', 
                'eccube.name01', 
                'eccube.name02')
                    ->join(\DB::raw('clotho_mercurop_eccube.dtb_customer as eccube'), function($j) {
                        $j->on('t_payment_group.main_customer_id', '=', DB::raw('eccube.customer_id '));
                    });

            if ($keyword['グループ名']) {
                $paymentgroup->where('m_item_detail_category.item_detail_category_name', 'like', '%'.$keyword['グループ名'].'%');
            }

            if($keyword['代表支払者']) {
                $paymentgroup->where('m_item_category.item_category_name', 'like', '%'.$keyword['代表支払者'].'%');
            }

            $paymentgroup = $paymentgroup->paginate($perPage);
        } else {
            $paymentgroup = TPaymentGroup::paginate($perPage);
        }

        return view('pop_up.paygroup_sub_form', compact('paymentgroup'));
    }



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

Aucun commentaire:

Enregistrer un commentaire