My table looks like below,
donation_requests
---------------------------------------------------------------
| id name donation_type_id donation_request_type_id
|--------------------------------------------------------------
| 1 xyz 1 3
| 2 pqr 3 2
| 3 abc 3 1
| 4 klm 4 1
donation_types
------------------------
| id name
-----------------------
| 1 jakat
| 2 sadka
| 3 lillah
| 4 fitra
donation_request_types
------------------------
| id name
-----------------------
| 1 widow
| 2 masjid
| 3 madresha
i want donation_request data with donation_types name and donation_request_types name In my DonationRequest model code is as below
public function donation_types()
{
return $this->belongsTo('App\DonationType','id','donation_type_id');
}
public function donation_request_types()
{
return $this->belongsTo('App\DonationRequestType','id','donation_request_type_id');
}
but in first two row i get proper result but for third row has same donation_type_id as 3 so it give blank and same as in donation_request_type_id