我已经将贷款表与投标表关联起来,其中单个贷款可以有多个投标。当我试图获得贷款时,我应该得到投标细节,但我无法得到。
我的实体是:
class Loan extends Base {
//....
/**
* @ORM'OneToMany(targetEntity="Bid", mappedBy="loan")
*/
protected $bids;
//....
}
class Bid extends Base {
//....
/**
* @ORM'ManyToOne(targetEntity="Loan", inversedBy="bids")
* @ORM'JoinColumn(name="loan_id", referencedColumnName="id",
onDelete="CASCADE")
*
*/
protected $loan;
//....
}
我的输出是(见贷款详细信息中的投标):
{
"loan_amount_required": 30000,
"interest_rate": 3,
"loan_duration": 1,
"loan_validity": 5,
"status": "active",
"loan_created": "2015-11-27 12:35:56",
"user": {
"fname": "",
"lname": "",
"email": "",
"password": "",
"is_active": true,
"random_number": ,
"role": "user",
"balance": 0,
"last_seen": "........",
"notify_me": true,
"id": 34
},
"bids": [
{}
],
"id": 71
}
在贷款构造函数中尝试此操作
// ...
use Doctrine'Common'Collections'ArrayCollection;
class Loan extends Base
{
// ...
public function __construct()
{
$this->bids = new ArrayCollection();
}
}