Closed tonyneurony closed 3 years ago
Hi @tonyneurony
Can you please let me know if you casted the meta
column to an array
as per the docs?
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
...
'meta' => 'array',
];
Hi @zbiller Yes, for sure. This actually happens on default Page model as well, when, for example u have a page seeded via seeder, thus the meta columns remains 'null' in DB
@tonyneurony
I've applied a fix for this issue.
It's available on version 2.2.0
.
Thanks for your support!
Description of the bug (screenshots might help):
When you add a HasMetaTags trait to a model, that previously had some entries in DB (for example i seed pages for Page model),
meta
column remainsnull
in DB, until you save that model in DB(so it saves the json data to meta column), you will be getting 'Invalid argument supplied for foreach()' error. The fix is quick: indisplayMetaTags()
method, wrap the foreach intoif (!empty($tags)) {
Steps to reproduce (fresh Varbox installation):