Skip to content

Commit

Permalink
Merge pull request #61 from tipoff/omnia/feature/17_update_keyword
Browse files Browse the repository at this point in the history
update keyword #17 [TGER-122]
  • Loading branch information
drewroberts authored Mar 18, 2021
2 parents c215034 + ef89476 commit c98b6d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
24 changes: 22 additions & 2 deletions src/Nova/Keyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

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;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Panel;
Expand Down Expand Up @@ -34,8 +36,26 @@ public function fieldsForIndex(NovaRequest $request)
public function fields(Request $request)
{
return array_filter([
Text::make('Phrase')->required()->creationRules('unique:keywords,phrase')->sortable(),
Text::make('Type')->required()->sortable(),
Text::make('Phrase')
->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'])
->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,

Expand Down

0 comments on commit c98b6d0

Please sign in to comment.