Closed sennewancour closed 1 month ago
Okay just discovered the problem. When the 'Relationship Name' field (hasmany or belongsto) in the blueprint is filled in with the wrong name for example 'Product' instead of 'product' it throws the error.
When you say "relationship name", are you talking about the "Resource" setting?
It's the setting in the blueprint
Ah okay! Yes, that's case sensitive and should match exactly with the relationship's method name in your model.
Allright took me a while to realise that ;) Thanks for the help!
Description
I'm loading a relationship called wishlistProducts (return $this->belongsToMany(Product::class, 'user_wishlistproducts', 'user_id', 'product_rentman_id', 'id', 'rentman_id');) on my User model, but it returns following error.
Object of class Illuminate\Database\Eloquent\Relations\BelongsToMany could not be converted to string
I call the relation with the following code. The {{ name }} tag is rendered the correct way, so the right user is called. ` {{ _currentUser = {user}; }}
`
Steps to reproduce
Environment
Environment Application Name: Statamic Laravel Version: 11.8.0 PHP Version: 8.2.16 Composer Version: 2.7.6 Environment: local Debug Mode: ENABLED URL: ambiance.test Maintenance Mode: OFF
Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED
Drivers Broadcasting: log Cache: statamic Database: mysql Logs: stack / single Mail: smtp Queue: sync Session: file
Statamic Addons: 3 Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 5.5.0 PRO
Statamic Addons joetannenbaum/antlers-stack-tags: 0.1.0 statamic-rad-pack/runway: 7.1.0 statamic/eloquent-driver: 4.0.0
Statamic Eloquent Driver Asset Containers: file Assets: file Blueprints: eloquent Collection Trees: eloquent Collections: eloquent Entries: eloquent Forms: eloquent Global Sets: eloquent Global Variables: eloquent Navigation Trees: eloquent Navigations: eloquent Revisions: eloquent Taxonomies: eloquent Terms: eloquent