statamic-rad-pack / runway

Eloquently manage your database models in Statamic.
https://statamic.com/runway
MIT License
107 stars 43 forks source link

Empty response for Assets on entry view route #460

Closed OleksiiBrylin closed 3 months ago

OleksiiBrylin commented 3 months ago

Description

I use Runway. I have Entry with Assets type field. After updating the Runway my assets disappeared from runway entry view page. I use antlers:

 {{ images }}{{ url }}{{ /images }}

instead of a list of images I get Statamic\Assets\OrderedQueryBuilder. And it returns empty array. Only {{ image | raw }} returns a list of images.

Steps to reproduce

  1. install the last version of Statamic 4.53.0
  2. require the last version of Runway 6.6.0
  3. create entry with Assets field (multiply items) with handle images
  4. add assets via admin panel
  5. set up runway route /test/{id}
  6. create antlers template with {{ images }}{{ url }}{{ /images }}
  7. open /test/{id} page
  8. no image url is present

Environment

Environment Application Name: Statamic Laravel Version: 9.52.15 PHP Version: 8.2.11 Composer Version: 2.6-dev+d2bd9836a604f5b475013c077706e6dc6f420e35 Environment: local Debug Mode: ENABLED URL: milsport.localhost Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: null Cache: statamic Database: mysql Logs: stack / daily Mail: log Queue: sync Session: file

Statamic Addons: 3 Antlers: runtime Sites: 4 (Deutsch, Français, Italiano, English) Stache Watcher: Enabled Static Caching: Disabled Version: 4.53.0 PRO

Statamic Addons appswithlove/statamic-one-click-content-translation: 4.62.0 statamic-rad-pack/runway: 6.6.0 statamic/seo-pro: 5.4.1

duncanmcclean commented 3 months ago

I'm unable to reproduce this on my local site, the Assets field is augmenting and returning correctly.

Can you ensure you've added the relevant cast to your model?

// app/Models/Product.php

protected $casts = [
    'images' => 'json',
];

I'm going to close this issue now. However, if you're still experiencing this issue after adding a cast to your model, leave a comment and I can re-open. Thanks!

OleksiiBrylin commented 3 months ago

Thank you! With the $casts it works