Skip to content

Commit

Permalink
Merge pull request #79 from tipoff/omnia/feature/25-Results
Browse files Browse the repository at this point in the history
Omnia/feature/25 results
  • Loading branch information
drewroberts authored Mar 27, 2021
2 parents b0091d4 + 89ef5f6 commit 241826c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function up()
$table->foreignIdFor(app('ranking'))->index();
$table->string('type')->index(); // Example: 'Organic', 'Local', 'Ads', 'Inline Video'
$table->unsignedTinyInteger('position')->index();
$table->foreignIdFor(app('result'), 'parent_id')->nullable(); // Parent Result

// resultable_id, resultable_type either Tipoff\Seo\Models\Webpage or Place
$table->morphs('resultable');
Expand Down
24 changes: 24 additions & 0 deletions src/Enum/ResultType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Tipoff\Seo\Enum;

use MabeEnum\Enum;

/**
* @method static TaxCode ORGANIC_LISTING()
* @method static TaxCode LOCAL_LISTING()
* @method static TaxCode FEATURED_SNIPPET()
* @method static TaxCode INLINE_VIDEO_LISTINGS()
* @method static TaxCode ADS()
* @psalm-immutable
*/
class ResultType extends Enum
{
const ORGANIC_LISTING = 'organic_listing';
const LOCAL_LISTING = 'local_listing';
const FEATURED_SNIPPET = 'featured_snippet';
const INLINE_VIDEO_LISTINGS = 'inline_video_listings';
const ADS = 'ads';
}
4 changes: 3 additions & 1 deletion src/Nova/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class Place extends BaseResource
public static $search = [
'id',
];

public static $group = 'SEO';

public static $displayInNavigation = false; //don't show resource in navigation

public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
Expand Down
4 changes: 3 additions & 1 deletion src/Nova/PlaceDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class PlaceDetails extends BaseResource
public static $search = [
'id',
];

public static $group = 'SEO';

public static $displayInNavigation = false; //don't show resource in navigation

public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
Expand Down
4 changes: 3 additions & 1 deletion src/Nova/PlaceHours.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class PlaceHours extends BaseResource
public static $search = [
'id',
];

public static $group = 'SEO';

public static $displayInNavigation = false; //don't show resource in navigation

public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
Expand Down
15 changes: 12 additions & 3 deletions src/Nova/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\MorphTo;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Panel;
use Tipoff\Seo\Enum\ResultType;
use Tipoff\Support\Nova\BaseResource;

class Result extends BaseResource
Expand All @@ -23,9 +24,11 @@ class Result extends BaseResource
public static $search = [
'id',
];

public static $group = 'SEO';

public static $displayInNavigation = false; //don't show resource in navigation

public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
Expand All @@ -36,7 +39,13 @@ public function fieldsForIndex(NovaRequest $request)
public function fields(Request $request)
{
return array_filter([
Text::make('Type')->required()->sortable(),
Select::make('Type')->options([
ResultType::ORGANIC_LISTING => 'Organic Listings',
ResultType::LOCAL_LISTING => 'Local Listings',
ResultType::FEATURED_SNIPPET => 'Featured Snippet',
ResultType::INLINE_VIDEO_LISTINGS => 'Inline Video Listings',
ResultType::ADS => 'Product',
])->required(),
Number::make('Position')->required()->min(0)->max(255)->sortable(),

nova('ranking') ? BelongsTo::make('Ranking', 'ranking', nova('ranking'))->sortable() : null,
Expand Down
2 changes: 2 additions & 0 deletions src/Nova/Webpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Webpage extends BaseResource

public static $group = 'SEO';

public static $displayInNavigation = false; //don't show resource in navigation

public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
Expand Down

0 comments on commit 241826c

Please sign in to comment.