PaulE
2 months ago
200
3
Nova

Allow creation of relationship resource

Posted 2 months ago by PaulE

In Nova I have two models;

  • Post
  • Tag

Both resources should be visible in the menu, however, tags are not allowed to be created. My TagPolicy has public function create() { return false; } which prevents the creation of tags from directly accessing the resource.

Now I want my Posts to have a tag, so I have added the relation to the fields. My tags show up, but the create button is hidden due to the TagPolicy previously defined.

From the docs I get the idea that it should be possible to add public function addTag to my PostPolicy in order to allow/deny the creation of a tag on my post, however, this only works if the create is allowed for tags from the TagPolicy.

Is there any way how I can bypass this logic and be able to define the policy so that I can only create a tag from the Post?

--

P.S. I know in the case of Post/Tags it should be Many to Many (attach, detach), but this is just an example

Please sign in or create an account to participate in this conversation.