Skip to content

Commit

Permalink
Nova User Management
Browse files Browse the repository at this point in the history
composer.json
-add tsung/nova-custom to be able to add deactive button

Nova Resource
-add onlyOnForms for HiddenField
  • Loading branch information
anditsung committed May 13, 2020
1 parent 952d6a7 commit 9dfb2de
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"php": ">=7.1.0",
"laravel/nova": "^2",
"spatie/laravel-permission": "^3",
"outhebox/nova-hidden-field": "^1.0"
"outhebox/nova-hidden-field": "^1.0",
"tsung/nova-custom": "*"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/Nova/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public function fields(Request $request)
->hideFromIndex(),

HiddenField::make('User', 'user_id')
->current_user_id(),
->current_user_id()
->onlyOnForms(),

BelongsTo::make(_('Created By'), 'user', User::class)
->onlyOnDetail(),
Expand Down
3 changes: 2 additions & 1 deletion src/Nova/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function fields(Request $request)
->rules(['required', Rule::in($guardOptions)]),

HiddenField::make('User', 'user_id')
->current_user_id(),
->current_user_id()
->onlyOnForms(),

BelongsTo::make(_('Created By'), 'user', User::class)
->onlyOnDetail(),
Expand Down
3 changes: 2 additions & 1 deletion src/Stub/Nova/User.stub
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class User extends ResourceForUser
->updateRules('nullable', 'string', 'min:8'),

HiddenField::make('User', 'user_id')
->current_user_id(),
->current_user_id()
->onlyOnForms(),

BelongsTo::make(_('Created By'), 'user', User::class)
->onlyOnDetail(),
Expand Down

0 comments on commit 9dfb2de

Please sign in to comment.