corcel
corcel copied to clipboard
make meta optional
- Corcel Version: 5
- Framework Name & Version: php vanilla
- PHP Version: 7
- Database Driver & Version: Mysql
Description:
I get
"meta": [
{
"meta_id": 1679,
"post_id": 560,
"meta_key": "_elementor_edit_mode",
"meta_value": "builder",
"value": "builder"
},
with each post I want to get metas manually not automatically this makes my api slower.
@jakejohns You should change:
public function getMeta($attribute)
{
if ($meta = $this->meta->{$attribute}) {
return $meta;
}
return null;
}
to
public function getMeta($attribute)
{
if ($meta = $this->meta()->where('meta_key',$attribute)->value('meta_value')) {
return $meta;
}
return null;
}
Now it doesn't go get all metas it only gets one meta the meta we asked for.