From a6251f8db2cb91481eb7d2e1d6df64f4d30d2e9e Mon Sep 17 00:00:00 2001 From: Toby Schrapel Date: Tue, 6 Nov 2018 12:51:13 -0500 Subject: [PATCH] Use trait instead of abstract class. (#20) --- README.md | 8 +++++--- src/{Resource.php => Tabs.php} | 5 +---- 2 files changed, 6 insertions(+), 7 deletions(-) rename src/{Resource.php => Tabs.php} (98%) diff --git a/README.md b/README.md index 7197d50..a85fc5b 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,14 @@ composer require arsenaltech/nova-tab ## Usage -Extend App\Nova\Resource from Arsenaltech\NovaTab\Resource +Add the Tabs trait to your App\Nova\Resource class. ```php -use Arsenaltech\NovaTab\Resource as TabResource; +use Arsenaltech\NovaTab\Tabs; -abstract class Resource extends TabResource +abstract class Resource extends NovaResource +{ + use Tabs; ``` Add the field to your resource in the `fields` method: diff --git a/src/Resource.php b/src/Tabs.php similarity index 98% rename from src/Resource.php rename to src/Tabs.php index 80220c0..c215799 100644 --- a/src/Resource.php +++ b/src/Tabs.php @@ -7,10 +7,8 @@ use Laravel\Nova\Resource as NovaResource; use Laravel\Nova\Http\Requests\NovaRequest; -abstract class Resource extends NovaResource +trait Tabs { - - public function updateFields(NovaRequest $request) { $updateFields = parent::updateFields($request); if(!$request->isMethod('get')) { @@ -87,5 +85,4 @@ protected function assignFieldsToTabs(NovaRequest $request, $fields) return $fields; } - }