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 %}
是否需要用這種方式定義專輯/圖像?