From 634657933549d628f0d4f589bc1a26e523e8f330 Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 10:41:22 -0400 Subject: [PATCH 01/14] [TGER-122] update permission 'create keywords' --- database/migrations/2021_02_02_100000_add_seo_permissions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2021_02_02_100000_add_seo_permissions.php b/database/migrations/2021_02_02_100000_add_seo_permissions.php index 48bb958..78f4fb3 100644 --- a/database/migrations/2021_02_02_100000_add_seo_permissions.php +++ b/database/migrations/2021_02_02_100000_add_seo_permissions.php @@ -22,7 +22,7 @@ public function up() 'create places' => ['Owner', 'Executive'], 'update places' => ['Owner', 'Executive'], 'view keywords' => ['Owner', 'Executive', 'Staff'], - 'create keywords' => ['Owner', 'Executive'], + 'create keywords' => ['Owner', 'Staff'], 'update keywords' => ['Owner', 'Executive'], 'view rankings' => ['Owner', 'Executive', 'Staff'], 'create rankings' => ['Owner', 'Executive'], From 9122709ef146cde8584f607f6f10b0c2ce750709 Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 10:55:04 -0400 Subject: [PATCH 02/14] [TGER-122] update Keyword migration, datetime tracking_requested_at, tracking_stopped_at --- database/migrations/2020_01_01_140000_create_keywords_table.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/migrations/2020_01_01_140000_create_keywords_table.php b/database/migrations/2020_01_01_140000_create_keywords_table.php index 7087eb6..d75eb7f 100644 --- a/database/migrations/2020_01_01_140000_create_keywords_table.php +++ b/database/migrations/2020_01_01_140000_create_keywords_table.php @@ -14,6 +14,8 @@ public function up() $table->id(); $table->string('phrase')->index()->unique(); $table->string('type')->index(); // Example: 'Branded', 'Generic', 'Local' + $table->dateTime('tracking_requested_at')->nullable(); + $table->dateTime('tracking_stopped_at')->nullable(); $table->foreignIdFor(app('keyword'), 'parent_id')->nullable(); $table->foreignIdFor(app('user'), 'creator_id'); From 954d7fe0202e971e0dfd2709c07859caf1fcb3c4 Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 11:38:38 -0400 Subject: [PATCH 03/14] [TGER-122] changed Type to Select with options --- src/Nova/Keyword.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index ba5c161..2c8c76c 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -7,6 +7,7 @@ use Illuminate\Http\Request; use Laravel\Nova\Fields\BelongsTo; use Laravel\Nova\Fields\ID; +use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Panel; @@ -35,7 +36,11 @@ public function fields(Request $request) { return array_filter([ Text::make('Phrase')->required()->creationRules('unique:keywords,phrase')->sortable(), - Text::make('Type')->required()->sortable(), + Select::make('Type')->options([ + 'Branded' => 'Branded', + 'Generic' => 'Generic', + 'Local' => 'Local', + ])->required(), nova('keyword') ? BelongsTo::make('Parent phrase', 'parent phrase', nova('keyword'))->nullable() : null, From 8c17f1369f6d85e3dbfa3fedd15fd9daef9e19fe Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 11:59:05 -0400 Subject: [PATCH 04/14] [TGER-122] changed relationship to parent keyword searchable by id --- src/Nova/Keyword.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index 2c8c76c..d031031 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -17,7 +17,7 @@ class Keyword extends BaseResource { public static $model = \Tipoff\Seo\Models\Keyword::class; - public static $title = 'phrase'; + public static $title = 'id'; public static $search = [ 'id', From d8d44cb908bf4c8ea8c949f7c9086389cd3989ce Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 12:17:35 -0400 Subject: [PATCH 05/14] [TGER-122] Nova Keyword updated rules --- src/Nova/Keyword.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index d031031..aaae827 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -35,7 +35,14 @@ public function fieldsForIndex(NovaRequest $request) public function fields(Request $request) { return array_filter([ - Text::make('Phrase')->required()->creationRules('unique:keywords,phrase')->sortable(), + Text::make('Phrase') + ->required() + ->rules('required', 'unique:keywords,phrase', function($attribute, $value, $fail) { + if (strtolower($value) !== $value) { + return $fail('The '.$attribute.' field must be lowercase.'); + } + }) + ->sortable(), Select::make('Type')->options([ 'Branded' => 'Branded', 'Generic' => 'Generic', From 5305635d0125bacefc7cc1623ed8bbb47d9d20af Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 16:19:37 +0000 Subject: [PATCH 06/14] Fix styling --- src/Nova/Keyword.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index aaae827..e1ebf25 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -37,7 +37,7 @@ public function fields(Request $request) return array_filter([ Text::make('Phrase') ->required() - ->rules('required', 'unique:keywords,phrase', function($attribute, $value, $fail) { + ->rules('required', 'unique:keywords,phrase', function ($attribute, $value, $fail) { if (strtolower($value) !== $value) { return $fail('The '.$attribute.' field must be lowercase.'); } From a101c26ebe5ecc97218153d4221b7a565d91308d Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 12:25:20 -0400 Subject: [PATCH 07/14] [TGER-122] Nova Keyword updated rules --- src/Nova/Keyword.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index aaae827..e63291f 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -47,7 +47,10 @@ public function fields(Request $request) 'Branded' => 'Branded', 'Generic' => 'Generic', 'Local' => 'Local', - ])->required(), + ]) + ->required() + ->rules('required') + ->sortable(), nova('keyword') ? BelongsTo::make('Parent phrase', 'parent phrase', nova('keyword'))->nullable() : null, From a1fa00cbe204142a61c82d8f436a56a91321a06b Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 12:31:31 -0400 Subject: [PATCH 08/14] [TGER-122] Nova Keyword add new datetime fields to Nova --- src/Nova/Keyword.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index e63291f..d8e95b8 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use Laravel\Nova\Fields\BelongsTo; +use Laravel\Nova\Fields\DateTime; use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; @@ -51,6 +52,8 @@ public function fields(Request $request) ->required() ->rules('required') ->sortable(), + DateTime::make('Tracking Requested At')->nullable(), + DateTime::make('Tracking Stopped At')->nullable(), nova('keyword') ? BelongsTo::make('Parent phrase', 'parent phrase', nova('keyword'))->nullable() : null, From aa8b457b0c305d45656b37d477e1359d44ce7187 Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 13:46:36 -0400 Subject: [PATCH 09/14] [TGER-122] Nova Keyword remove required method, keep rules required --- src/Nova/Keyword.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index 8fbcb17..a786dee 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -37,8 +37,7 @@ public function fields(Request $request) { return array_filter([ Text::make('Phrase') - ->required() - ->rules('required', 'unique:keywords,phrase', function ($attribute, $value, $fail) { + ->rules('required', 'unique:keywords,phrase', function($attribute, $value, $fail) { if (strtolower($value) !== $value) { return $fail('The '.$attribute.' field must be lowercase.'); } @@ -49,7 +48,6 @@ public function fields(Request $request) 'Generic' => 'Generic', 'Local' => 'Local', ]) - ->required() ->rules('required') ->sortable(), DateTime::make('Tracking Requested At')->nullable(), From 1971689ae578a8f620e354de27ac811ef24aba12 Mon Sep 17 00:00:00 2001 From: devjk1 Date: Tue, 16 Mar 2021 17:47:17 +0000 Subject: [PATCH 10/14] Fix styling --- src/Nova/Keyword.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index a786dee..29d0bdd 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -37,7 +37,7 @@ public function fields(Request $request) { return array_filter([ Text::make('Phrase') - ->rules('required', 'unique:keywords,phrase', function($attribute, $value, $fail) { + ->rules('required', 'unique:keywords,phrase', function ($attribute, $value, $fail) { if (strtolower($value) !== $value) { return $fail('The '.$attribute.' field must be lowercase.'); } From f552e3ec859ffd876e52871eed0d05c428993f38 Mon Sep 17 00:00:00 2001 From: devjk1 Date: Wed, 17 Mar 2021 17:11:22 -0400 Subject: [PATCH 11/14] [TGER-122] Nova Keyword, make rules into array --- src/Nova/Keyword.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index 29d0bdd..507baf2 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -37,18 +37,22 @@ public function fields(Request $request) { return array_filter([ Text::make('Phrase') - ->rules('required', 'unique:keywords,phrase', function ($attribute, $value, $fail) { - if (strtolower($value) !== $value) { - return $fail('The '.$attribute.' field must be lowercase.'); + ->rules([ + 'required', + 'unique:keywords,phrase', + function ($attribute, $value, $fail) { + if (strtolower($value) !== $value) { + return $fail('The '.$attribute.' field must be lowercase.'); + } } - }) + ]) ->sortable(), Select::make('Type')->options([ 'Branded' => 'Branded', 'Generic' => 'Generic', 'Local' => 'Local', ]) - ->rules('required') + ->rules(['required']) ->sortable(), DateTime::make('Tracking Requested At')->nullable(), DateTime::make('Tracking Stopped At')->nullable(), From 007f135ccc88713dea35a4847cd2304ea9bc8a2c Mon Sep 17 00:00:00 2001 From: devjk1 Date: Wed, 17 Mar 2021 21:12:08 +0000 Subject: [PATCH 12/14] Fix styling --- src/Nova/Keyword.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index 507baf2..31977b7 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -38,13 +38,13 @@ public function fields(Request $request) return array_filter([ Text::make('Phrase') ->rules([ - 'required', - 'unique:keywords,phrase', + 'required', + 'unique:keywords,phrase', function ($attribute, $value, $fail) { if (strtolower($value) !== $value) { return $fail('The '.$attribute.' field must be lowercase.'); } - } + }, ]) ->sortable(), Select::make('Type')->options([ From a0a1d3c32da8e37741f72fc6ac6fcc7858abe11d Mon Sep 17 00:00:00 2001 From: Drew Roberts Date: Thu, 18 Mar 2021 11:55:05 -0400 Subject: [PATCH 13/14] Remove ability for staff to create keywords --- database/migrations/2021_02_02_100000_add_seo_permissions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2021_02_02_100000_add_seo_permissions.php b/database/migrations/2021_02_02_100000_add_seo_permissions.php index 78f4fb3..48bb958 100644 --- a/database/migrations/2021_02_02_100000_add_seo_permissions.php +++ b/database/migrations/2021_02_02_100000_add_seo_permissions.php @@ -22,7 +22,7 @@ public function up() 'create places' => ['Owner', 'Executive'], 'update places' => ['Owner', 'Executive'], 'view keywords' => ['Owner', 'Executive', 'Staff'], - 'create keywords' => ['Owner', 'Staff'], + 'create keywords' => ['Owner', 'Executive'], 'update keywords' => ['Owner', 'Executive'], 'view rankings' => ['Owner', 'Executive', 'Staff'], 'create rankings' => ['Owner', 'Executive'], From ef8947683d6fedafa7ad3b547bf3cba323695b57 Mon Sep 17 00:00:00 2001 From: Drew Roberts Date: Thu, 18 Mar 2021 11:56:19 -0400 Subject: [PATCH 14/14] Use keyword phrase as resource title in admin --- src/Nova/Keyword.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nova/Keyword.php b/src/Nova/Keyword.php index 31977b7..67685f3 100644 --- a/src/Nova/Keyword.php +++ b/src/Nova/Keyword.php @@ -18,7 +18,7 @@ class Keyword extends BaseResource { public static $model = \Tipoff\Seo\Models\Keyword::class; - public static $title = 'id'; + public static $title = 'phrase'; public static $search = [ 'id',