File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace KirschbaumDevelopment \NovaInlineRelationship \Integrations \Contracts ;
4+
5+ interface ThirdPartyContract
6+ {
7+ /**
8+ * ThirdPartyContract constructor.
9+ *
10+ * @param $object
11+ */
12+ public function __construct ($ object );
13+
14+ /**
15+ * Fields array from object.
16+ *
17+ * @return array
18+ */
19+ public function fields (): array ;
20+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace KirschbaumDevelopment \NovaInlineRelationship \Integrations ;
4+
5+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Contracts \ThirdPartyContract ;
6+
7+ class Field implements ThirdPartyContract
8+ {
9+ /**
10+ * @var mixed
11+ */
12+ private $ object ;
13+
14+ /**
15+ * ThirdPartyContract constructor.
16+ *
17+ * @param $object
18+ */
19+ public function __construct ($ object )
20+ {
21+ $ this ->object = $ object ;
22+ }
23+
24+ /**
25+ * Fields array from object.
26+ *
27+ * @return array
28+ */
29+ public function fields (): array
30+ {
31+ return [$ this ->object ];
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace KirschbaumDevelopment \NovaInlineRelationship \Integrations ;
4+
5+ use LeadMarvels \Campaigns \Services \QueryClauses \Contracts \WhereInterface ;
6+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Field as FieldInterface ;
7+
8+ class Integrate
9+ {
10+ public static function fields ($ object ): array
11+ {
12+ $ basename = class_basename (get_class ($ object ));
13+ $ class = "\\KirschbaumDevelopment \\NovaInlineRelationship \\Integrations \\{$ basename }" ;
14+
15+ return class_exists ($ class )
16+ ? (new $ class ($ object ))->fields ()
17+ : (new FieldInterface ($ object ))->fields ();
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace KirschbaumDevelopment \NovaInlineRelationship \Integrations ;
4+
5+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Contracts \ThirdPartyContract ;
6+
7+ class NovaDependencyContainer implements ThirdPartyContract
8+ {
9+ /**
10+ * @var \Laravel\Nova\Panel
11+ */
12+ private $ object ;
13+
14+ /**
15+ * ThirdPartyContract constructor.
16+ *
17+ * @param $object
18+ */
19+ public function __construct ($ object )
20+ {
21+ $ this ->object = $ object ;
22+ }
23+
24+ /**
25+ * Fields array from object.
26+ *
27+ * @return array
28+ */
29+ public function fields (): array
30+ {
31+ return $ this ->object ->meta ['fields ' ];
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace KirschbaumDevelopment \NovaInlineRelationship \Integrations ;
4+
5+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Contracts \ThirdPartyContract ;
6+
7+ class Panel implements ThirdPartyContract
8+ {
9+ /**
10+ * @var \Laravel\Nova\Panel
11+ */
12+ private $ object ;
13+
14+ /**
15+ * ThirdPartyContract constructor.
16+ *
17+ * @param $object
18+ */
19+ public function __construct ($ object )
20+ {
21+ $ this ->object = $ object ;
22+ }
23+
24+ /**
25+ * Fields array from object.
26+ *
27+ * @return array
28+ */
29+ public function fields (): array
30+ {
31+ return $ this ->object ->data ;
32+ }
33+ }
Original file line number Diff line number Diff line change 55use Laravel \Nova \Nova ;
66use Laravel \Nova \Panel ;
77use Illuminate \Database \Eloquent \Model ;
8+ use Epartment \NovaDependencyContainer \NovaDependencyContainer ;
89use KirschbaumDevelopment \NovaInlineRelationship \NovaInlineRelationship ;
10+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Integrate ;
911use KirschbaumDevelopment \NovaInlineRelationship \Contracts \RelationshipObservable ;
12+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Field as FieldInterface ;
13+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Panel as PanelInterface ;
14+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \Contracts \ThirdPartyContract ;
15+ use KirschbaumDevelopment \NovaInlineRelationship \Integrations \NovaDependencyContainer as NovaDependencyContainerInterface ;
1016use KirschbaumDevelopment \NovaInlineRelationship \Helpers \NovaInlineRelationshipHelper ;
1117
1218class NovaInlineRelationshipObserver
@@ -96,9 +102,7 @@ protected function getModelRelationships(Model $model)
96102 {
97103 return collect (Nova::newResourceFromModel ($ model )->fields (request ()))
98104 ->flatMap (function ($ value ) {
99- return $ value instanceof Panel
100- ? $ value ->data
101- : [$ value ];
105+ return Integrate::fields ($ value );
102106 })
103107 ->filter (function ($ value ) {
104108 return $ value ->component === 'nova-inline-relationship ' ;
You can’t perform that action at this time.
0 commit comments