From ad39b1e0cd64711698009a5b4cacc737a7405525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Sun, 31 Dec 2023 13:27:51 +0100 Subject: [PATCH] cleanup --- src/Traits/InteractsWithTurbo.php | 16 ++++++++++++++++ src/Widgets/Widget.php | 10 ++-------- tests/Fields/BelongsToTest.php | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/Traits/InteractsWithTurbo.php create mode 100644 tests/Fields/BelongsToTest.php diff --git a/src/Traits/InteractsWithTurbo.php b/src/Traits/InteractsWithTurbo.php new file mode 100644 index 00000000..225a42f2 --- /dev/null +++ b/src/Traits/InteractsWithTurbo.php @@ -0,0 +1,16 @@ +hasHeader('Turbo-Frame'); + } +} diff --git a/src/Widgets/Widget.php b/src/Widgets/Widget.php index a625428c..a2c18bd9 100644 --- a/src/Widgets/Widget.php +++ b/src/Widgets/Widget.php @@ -5,6 +5,7 @@ use Cone\Root\Http\Controllers\WidgetController; use Cone\Root\Traits\Authorizable; use Cone\Root\Traits\HasAttributes; +use Cone\Root\Traits\InteractsWithTurbo; use Cone\Root\Traits\Makeable; use Cone\Root\Traits\RegistersRoutes; use Cone\Root\Traits\ResolvesVisibility; @@ -17,6 +18,7 @@ abstract class Widget implements Arrayable { use Authorizable; use HasAttributes; + use InteractsWithTurbo; use Makeable; use RegistersRoutes; use ResolvesVisibility; @@ -73,14 +75,6 @@ public function data(Request $request): array ]); } - /** - * Determine if the request is Turbo request. - */ - public function isTurboRequest(Request $request): bool - { - return $request->hasHeader('Turbo-Frame'); - } - /** * The routes should be registered. */ diff --git a/tests/Fields/BelongsToTest.php b/tests/Fields/BelongsToTest.php new file mode 100644 index 00000000..5650ef5f --- /dev/null +++ b/tests/Fields/BelongsToTest.php @@ -0,0 +1,17 @@ +