【发布时间】:2016-07-03 09:43:32
【问题描述】:
我有两个模型
Invoice
amount
关系如下
namespace App;
use Illuminate\Database\Eloquent\Model;
class Invoice extends Model
{
//
protected $table = 'event_invoice';
protected $primaryKey = 'Id';
/*
* An invoice can has many payments
*
*/
public function payments(){
return $this->hasMany('App\paymentrecieved');
}
}
现在我正在尝试用这样的付款方式检索发票
$allinvoice = Invoice::with(['payments', 'comments'])->where( DB::raw('year(DueDate)'), $year)->get();
但是当我 dd() 时我得到这样的对象
Collection {#1191 ▼
#items: array:390 [▼
0 => Invoice {#750 ▶}
1 => Invoice {#751 ▶}
2 => Invoice {#752 ▼
#table: "event_invoice"
#primaryKey: "Id"
#connection: null
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:38 [ …38]
#original: array:38 [ …38]
#relations: array:1 [ …1]
#hidden: []
#visible: []
#appends: []
#fillable: []
#guarded: array:1 [ …1]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
您可以在数组中看到这些部分,它应该包含表格中的详细信息,但它只是给了我表格字段的计数,
#attributes: array:38 [ …38]
#original: array:38 [ …38]
#relations: array:1 [ …1]
【问题讨论】: