Answer the question
In order to leave comments, you need to log in
How to pass object in Resource format from blade to VUE?
You need to pass the product in resource format to the Vue component from the template blade.
I know that it can be done
<sticker-statuses
:object="{{json_encode($product)}}"
>
</sticker-statuses>
<sticker-statuses
:object= new ProductResource($product)
>
</sticker-statuses>
:object="{{json_encode($product->toResource())}}"
public function toResource()
{
return new ProductResource($this);
}
Answer the question
In order to leave comments, you need to log in
How can js accept a php class? What do you think should be in :object physically ? There can only be a line, what can it be? A magical php-class serializer that js can decipher and understand?
There can only be json, because js understands it and makes a js object out of it automatically. Therefore, your current decision is the final decision.
:resource="{{ json_encode($users->toResponse($request)->getData()) }}"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question