Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

There are two types of users in my application, Professional and Consumer. Professional can add their area_of_services(aos), and they can add multiple aos.

A consumer can submit a service request; while submitting the request, a consumer has to choose an aos related to the request. If a professional is logged in, all requests which come under his aos should be listed. To make it happen, I need to join these tables RFQ(requests table), AOS(area of services table), Legal Professional(Professionals Table). Right now, I am doing it by fetching aos_ids from the professional's table, and with the use of explode, I took values and passing the query inside for each. I need to work with a proper JOIN win Eloquent. I am working with Laravel 8.

Controller

public function rfq_plp()
{
    $lp_id = Session::get('lp_id');
    $aos_of_plp = LpProfile::where('lp_profile_id', $lp_id)->first()->aos;
    $aosnew = explode(',', $aos_of_plp);

    foreach ($aosnew as $aosid) {
        $rfqs[] = Rfq::join('areaof_specilizations', 
            'areaof_specilizations.aos_id', '=', 'rfqs.aos')
            ->leftjoin('countries as c', 'c.id', '=', 'rfqs.country_cs')
            ->leftjoin('countries as rs', 'rs.id', '=', 'rfqs.country_rs')
            -> where('rfqs.aos', '=', $aosid)
            ->get(['rs.country_name as rs_name', 
         'c.country_name as cs_name', 'rfqs.*',
                'areaof_specilizations.aos_name']);
    }

    dd($rfqs->l_issue);
}

My RFQ(Request Table) RFQ(Request) Table

Professional Table -

Professional Table aos values are comma-separated. I need to fetch the record from the RFQ table with aos id(single aos id) of the current professional.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...