You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i found in stapler docs that it should return attachment sizes with full path when returning data as json, but it does not seem to work with laravel-stapler
The stapler trait doesn't currently 'automagically' add it when you cast to JSON, so you'll need to handle this yourself. One option is to add it to the toArray() method of your model like this:
/**
* Convert the model instance to an array.
*
* @return array
*/
public function toArray()
{
return array_merge(parent::toArray(), ['avatar' => $this->attachments['avatar']]);
}
It'll then be encoded to JSON along with the rest of the model attributes/relationships.
i found in stapler docs that it should return attachment sizes with full path when returning data as json, but it does not seem to work with laravel-stapler
https://github.com/CodeSleeve/stapler/blob/master/docs/attachments.md
The text was updated successfully, but these errors were encountered: