2016-04-25 25 views
0

我已使用的hasMany和屬於關聯但我沒有得到任何結果顯示並 {{ dump(images) }}{{ dump(albums) }}Object variables NULL 0 NULL創建於octobercms

任何想法,爲什麼創造了我的模特形象和專輯之間的前端關係的前端關係關係沒有被拾起?

專輯

public $hasMany = [ 
'images' => [ 'Acme\Library\Models\Image' ,'key'=>'album_id'], 
]; 

圖片

public $belongsTo = [ 
'albums' => ['Acme\Library\Models\Album'] 
]; 

專輯,details.htm

{{ dump(images) }} 
{% for image in images %} 
{{image.id|raw }} 
{% endfor %} 

,如果我上{{ dump(record) }}運行轉儲我得到

Object variables 
Acme\Library\Models\Album 
bootValidation() method Boot the validation trait for this model. 
forceSave() method Force save the model even if validation fails. 
validate() method Validate the model instance 
isAttributeRequired() method Determines if an attribute is required based  on the validation rules. 
errors() method Get validation error message collection for the Model 
validating() method Create a new native event for handling beforeValidate(). 
validated() method Create a new native event for handling afterValidate(). 
rules array(0)  
timestamps boolean 
table string 
relationConfig string 
hasMany array(1) 

我可以看到使用builder插件定義了記錄{% set records = builderList.records %}

是否需要用這種方式定義專輯/圖像?

回答

1

我發送記錄變量到視圖和記錄是一個相冊的實例,您可以通過這種方式訪問​​您的圖像。

{% for image in record.images %} 
    {{image.id|raw }} 
{% endfor %}