Support the ongoing development of Laravel.io →
Database
Last updated 2 years ago.
0

Umm your question is too vague. What kind of data are you needing? Joins are done with the join method from the query builder, be warned tables with the same column names get overwritten.

0

I need data like

id name address text

1 sam Europe sample text

0

I used below method and the result is getting. Is this method is correct?

$customerdetails = Customeraddress::where('customer_id', 1)
            ->select('company', 'firstname', 'lastname', 'street', 'city', 'customer_id')
            ->first();
        $customerhistory = Customerhistory::where('customer_id', 1)
            ->select('freetext', 'DATE("created_at")')
            ->get();
        return view('pages.social',['customerdetails' => $customerdetails, 'customerhistory' => $customerhistory]);
0

Your customer model should have a history and address relationships. You can then return the data from any related table through the customer model as well as query it's relationships allowing you to get users by address, history, etc.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.