I have three resources in Laravel Nova:
Post - id, name
Comment - id, comment, post_id
Rating - id, rating, comment_id
My Code In Rating resources' field:
public function fields(Request $request)
{
return [
BelongsTo::make('Post', 'comment', Post::class)->withMeta([ 'belongsToId' => isset($this->comment['post']['id']) ? $this->comment['post']['id'] : null, ])->displayUsing(function ($comment) { return $comment->post->name; }),
];
}
I wrote a BelongsTo field for getting the comment for a Rating and perform CRUD operations. But now I want to update my Post details too from the Rating Resource. How can I achieve this?. I'm able to display the Post name on my Rating resources' index and detail page. But it fails when I try to update/insert any Post Details from Rating resource. Because it tries to insert/update the data into Rating resource and not into the comment resource.
I will be glad if someone could provide me a workaround for this problem. Thank you.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c4vRdg
via IFTTT
Aucun commentaire:
Enregistrer un commentaire