Skip to content

Commit

Permalink
Use new slug field in Laravel Nova #9
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts committed Sep 18, 2020
1 parent e6e3e08 commit 233f4fd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^7.3",
"benjaminhirsch/nova-slug-field": "^1.2",
"laravel/nova": "^3.10.0",
"drewroberts/media": "^1.0"
},
"require-dev": {
Expand Down
13 changes: 6 additions & 7 deletions src/Nova/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace DrewRoberts\Blog\Nova;

use Benjaminhirsch\NovaSlugField\Slug;
use Benjaminhirsch\NovaSlugField\TextWithSlug;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\Slug;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Http\Requests\NovaRequest;
Expand Down Expand Up @@ -43,8 +42,8 @@ public function fieldsForIndex(NovaRequest $request)
public function fields(Request $request)
{
return [
TextWithSlug::make('Title')->slug('slug'),
Slug::make('Slug')->disableAutoUpdateWhenUpdating(),
Text::make('Title')->required(),
Slug::make('Slug')->from('Title'),
DateTime::make('Published', 'published_at'),
BelongsTo::make('Series'),
BelongsTo::make('Author', 'author', 'App\Nova\User')->nullable(),
Expand Down Expand Up @@ -72,9 +71,9 @@ protected function dataFields()
{
return [
ID::make(),
DateTime::make('Created At')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Updated By', 'updater', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Updated At')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Created At')->exceptOnForms(),
BelongsTo::make('Updated By', 'updater', 'App\Nova\User')->exceptOnForms(),
DateTime::make('Updated At')->exceptOnForms(),
];
}

Expand Down
15 changes: 7 additions & 8 deletions src/Nova/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace DrewRoberts\Blog\Nova;

use Benjaminhirsch\NovaSlugField\Slug;
use Benjaminhirsch\NovaSlugField\TextWithSlug;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\Slug;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Http\Requests\NovaRequest;
Expand Down Expand Up @@ -43,8 +42,8 @@ public function fieldsForIndex(NovaRequest $request)
public function fields(Request $request)
{
return [
TextWithSlug::make('Title')->slug('slug'),
Slug::make('Slug')->disableAutoUpdateWhenUpdating(),
Text::make('Title')->required(),
Slug::make('Slug')->from('Title'),
BelongsTo::make('Topic'),
Textarea::make('Note')->nullable(),

Expand Down Expand Up @@ -74,10 +73,10 @@ protected function dataFields()
{
return [
ID::make(),
BelongsTo::make('Created By', 'updater', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Created At')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Updated By', 'updater', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Updated At')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Created By', 'updater', 'App\Nova\User')->exceptOnForms(),
DateTime::make('Created At')->exceptOnForms(),
BelongsTo::make('Updated By', 'updater', 'App\Nova\User')->exceptOnForms(),
DateTime::make('Updated At')->exceptOnForms(),
];
}

Expand Down
15 changes: 7 additions & 8 deletions src/Nova/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace DrewRoberts\Blog\Nova;

use Benjaminhirsch\NovaSlugField\Slug;
use Benjaminhirsch\NovaSlugField\TextWithSlug;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\Slug;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Http\Requests\NovaRequest;
Expand Down Expand Up @@ -43,8 +42,8 @@ public function fieldsForIndex(NovaRequest $request)
public function fields(Request $request)
{
return [
TextWithSlug::make('Title')->slug('slug'),
Slug::make('Slug')->disableAutoUpdateWhenUpdating(),
Text::make('Title')->required(),
Slug::make('Slug')->from('Title'),
Textarea::make('Note')->nullable(),

new Panel('Content Fields', $this->contentFields()),
Expand Down Expand Up @@ -74,10 +73,10 @@ protected function dataFields()
{
return [
ID::make(),
BelongsTo::make('Created By', 'updater', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Created At')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Updated By', 'updater', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Updated At')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Created By', 'updater', 'App\Nova\User')->exceptOnForms(),
DateTime::make('Created At')->exceptOnForms(),
BelongsTo::make('Updated By', 'updater', 'App\Nova\User')->exceptOnForms(),
DateTime::make('Updated At')->exceptOnForms(),
];
}

Expand Down

0 comments on commit 233f4fd

Please sign in to comment.