From da7752c465de9eadb8362535e563371c43e0beea Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 4 Mar 2022 19:16:40 +1100 Subject: [PATCH] Nesting testing --- config/repeater_country_brothers.yaml | 11 +++++++++++ config/repeater_country_sisters.yaml | 6 ++++++ models/Country.php | 4 ++-- models/CountryBrother.php | 11 +++++++++++ models/RepeaterItem.php | 7 +++++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/config/repeater_country_brothers.yaml b/config/repeater_country_brothers.yaml index f3b84fa..f0a7882 100644 --- a/config/repeater_country_brothers.yaml +++ b/config/repeater_country_brothers.yaml @@ -19,3 +19,14 @@ gallery: mode: image imageWidth: 200 imageHeight: 200 + +sister: + name: Sister + icon: icon-refresh + fields: + sisters: + label: Sister + prompt: Add sister + span: full + type: repeater + form: $/october/test/config/repeater_country_sisters.yaml diff --git a/config/repeater_country_sisters.yaml b/config/repeater_country_sisters.yaml index 7ead4b6..a7a66af 100644 --- a/config/repeater_country_sisters.yaml +++ b/config/repeater_country_sisters.yaml @@ -8,3 +8,9 @@ fields: subtitle: label: Suburb span: full + photos: + label: Photos + type: fileupload + mode: image + imageWidth: 200 + imageHeight: 200 diff --git a/models/Country.php b/models/Country.php index 3a90534..f2f17e5 100644 --- a/models/Country.php +++ b/models/Country.php @@ -20,7 +20,7 @@ class Country extends Model public $table = 'october_test_countries'; /** - * @var array Guarded fields + * @var array guarded fields */ protected $guarded = []; @@ -30,7 +30,7 @@ class Country extends Model protected $fillable = []; /** - * @var array Jsonable fields + * @var array jsonable fields */ protected $jsonable = ['pages', 'states', 'locations', 'content', 'notes']; diff --git a/models/CountryBrother.php b/models/CountryBrother.php index 5622388..958547f 100644 --- a/models/CountryBrother.php +++ b/models/CountryBrother.php @@ -18,4 +18,15 @@ class CountryBrother extends Model public $attachMany = [ 'photos' => \System\Models\File::class, ]; + + /** + * @var array hasMany + */ + public $hasMany = [ + 'sisters' => [ + RepeaterItem::class, + 'key' => 'parent_id', + 'delete' => true + ], + ]; } diff --git a/models/RepeaterItem.php b/models/RepeaterItem.php index da6c288..ca41066 100644 --- a/models/RepeaterItem.php +++ b/models/RepeaterItem.php @@ -32,6 +32,13 @@ class RepeaterItem extends Model */ protected $fieldValues = []; + /** + * @var array attachMany + */ + public $attachMany = [ + 'photos' => \System\Models\File::class, + ]; + /** * afterFetch */