Skip to content

Commit

Permalink
Reference the correct user resource in Nova #8
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts committed Dec 20, 2020
1 parent 0249211 commit 36fef41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Nova/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Panel;
use Laravel\Nova\Nova;
use Laravel\Nova\Resource;
use Silvanite\NovaFieldCloudinary\Fields\CloudinaryImage;

Expand Down Expand Up @@ -40,7 +41,7 @@ public function fields(Request $request)
return [
CloudinaryImage::make('Image', 'filename')
->storeAs(function (Request $request) {
return 'img-'.sha1(time());
return 'img-' . sha1(time());
}),
Text::make('Width')->sortable(), // Want to auto generate from upload
Text::make('Height')->sortable(), // Want to auto generate from upload
Expand All @@ -57,9 +58,11 @@ public function fields(Request $request)

protected function dataFields()
{
$userResource = Nova::resourceForModel(getModelForGuard($this->guard_name));

return [
ID::make(),
BelongsTo::make('Created By', 'creator', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Created By', 'creator', $userResource)->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Created At')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Updated At')->hideWhenCreating()->hideWhenUpdating(),
];
Expand Down
5 changes: 4 additions & 1 deletion src/Nova/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Nova;
use Laravel\Nova\Panel;
use Laravel\Nova\Resource;

Expand Down Expand Up @@ -50,9 +51,11 @@ public function fields(Request $request)

protected function dataFields()
{
$userResource = Nova::resourceForModel(getModelForGuard($this->guard_name));

return [
ID::make(),
BelongsTo::make('Created By', 'creator', 'App\Nova\User')->hideWhenCreating()->hideWhenUpdating(),
BelongsTo::make('Created By', 'creator', $userResource)->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Created At')->hideWhenCreating()->hideWhenUpdating(),
DateTime::make('Updated At')->hideWhenCreating()->hideWhenUpdating(),
];
Expand Down

0 comments on commit 36fef41

Please sign in to comment.