-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add Workbench examples to use the field with Flexible and Repeater
- Loading branch information
1 parent
25faafc
commit 0a1f220
Showing
12 changed files
with
362 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,21 @@ providers: | |
- Oneduo\NovaFileManager\ToolServiceProvider | ||
- Workbench\App\Providers\NovaServiceProvider | ||
|
||
migrations: true | ||
migrations: | ||
- workbench/database/migrations | ||
|
||
seeders: | ||
- Workbench\Database\Seeders\DatabaseSeeder | ||
|
||
workbench: | ||
start: /nova | ||
user: [email protected] | ||
build: | ||
- asset-publish | ||
- create-sqlite-db | ||
- db:wipe | ||
- migrate:refresh | ||
- storage:link | ||
assets: | ||
- nova-assets | ||
sync: [] | ||
|
@@ -23,3 +26,7 @@ purge: | |
directories: | ||
- lang/* | ||
- public/vendor/* | ||
env: | ||
- AUTH_MODEL=Workbench\App\Models\User | ||
- FILESYSTEM_DRIVER=public | ||
- APP_URL=http://localhost:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Oneduo\NovaFileManager\Casts\Asset; | ||
use Whitecube\NovaFlexibleContent\Concerns\HasFlexible; | ||
use Whitecube\NovaFlexibleContent\Value\FlexibleCast; | ||
|
||
class Page extends Model | ||
{ | ||
use HasFlexible; | ||
|
||
protected $fillable = [ | ||
'title', | ||
'slug', | ||
'image', | ||
'content', | ||
]; | ||
|
||
protected $casts = [ | ||
'image' => Asset::class, | ||
'content' => FlexibleCast::class, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Models; | ||
|
||
use Illuminate\Foundation\Auth\User as Authenticable; | ||
|
||
class User extends Authenticable | ||
{ | ||
protected $fillable = [ | ||
'name', | ||
'email', | ||
'email_verified_at', | ||
'password', | ||
'profile', | ||
]; | ||
|
||
protected $casts = [ | ||
'profile' => 'array', | ||
]; | ||
} |
23 changes: 23 additions & 0 deletions
23
workbench/app/Nova/Flexible/Layouts/ImageAndCaptionLayout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Nova\Flexible\Layouts; | ||
|
||
use Laravel\Nova\Fields\Text; | ||
use Oneduo\NovaFileManager\FileManager; | ||
use Whitecube\NovaFlexibleContent\Layouts\Layout; | ||
|
||
class ImageAndCaptionLayout extends Layout | ||
{ | ||
protected $name = 'imageandcaptionlayout'; | ||
|
||
protected $title = 'ImageAndCaptionLayout'; | ||
|
||
public function fields(): array | ||
{ | ||
return [ | ||
FileManager::make('Image', 'image')->nullable(), | ||
Text::make('Caption', 'caption')->nullable(), | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Nova; | ||
|
||
use Laravel\Nova\Fields\ID; | ||
use Laravel\Nova\Fields\Markdown; | ||
use Laravel\Nova\Fields\Slug; | ||
use Laravel\Nova\Fields\Text; | ||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
use Laravel\Nova\Panel; | ||
use Laravel\Nova\Resource; | ||
use Oneduo\NovaFileManager\FileManager; | ||
use Whitecube\NovaFlexibleContent\Flexible; | ||
use Workbench\App\Nova\Flexible\Layouts\ImageAndCaptionLayout; | ||
|
||
class Page extends Resource | ||
{ | ||
/** | ||
* The model the resource corresponds to. | ||
* | ||
* @var string | ||
*/ | ||
public static $model = \Workbench\App\Models\Page::class; | ||
|
||
/** | ||
* The single value that should be used to represent the resource when being displayed. | ||
* | ||
* @var string | ||
*/ | ||
public static $title = 'title'; | ||
|
||
/** | ||
* The columns that should be searched. | ||
* | ||
* @var array | ||
*/ | ||
public static $search = [ | ||
'id', 'title', | ||
]; | ||
|
||
/** | ||
* Get the fields displayed by the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function fields(NovaRequest $request) | ||
{ | ||
return [ | ||
ID::make()->sortable(), | ||
|
||
Text::make('Title') | ||
->sortable() | ||
->rules('required', 'max:255'), | ||
|
||
Slug::make('Slug') | ||
->from('Title') | ||
->rules('required', 'max:255'), | ||
|
||
FileManager::make('Image') | ||
->rules('required'), | ||
|
||
Panel::make('Content', [ | ||
Flexible::make('Content') | ||
->addLayout(ImageAndCaptionLayout::class) | ||
->fullWidth(), | ||
|
||
]), | ||
|
||
]; | ||
} | ||
|
||
/** | ||
* Get the cards available for the request. | ||
* | ||
* @return array | ||
*/ | ||
public function cards(NovaRequest $request) | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the filters available for the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function filters(NovaRequest $request) | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the lenses available for the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function lenses(NovaRequest $request) | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the actions available for the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function actions(NovaRequest $request) | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Workbench\App\Nova\Repeater; | ||
|
||
use Laravel\Nova\Fields\Repeater\Repeatable; | ||
use Laravel\Nova\Fields\Text; | ||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
use Oneduo\NovaFileManager\FileManager; | ||
|
||
class UserInfoItem extends Repeatable | ||
{ | ||
public function fields(NovaRequest $request): array | ||
{ | ||
return [ | ||
Text::make('Card'), | ||
FileManager::make('Image')->wrapper('repeater'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.