Helper for custom field to get by slug

This commit is contained in:
harshjagad20
2021-05-22 13:24:10 +05:30
parent 3f0008ec95
commit 5ccc9eba4c
2 changed files with 12 additions and 0 deletions

View File

@ -591,4 +591,9 @@ class Invoice extends Model implements HasMedia
'{INVOICE_LINK}' => url('/customer/invoices/pdf/'.$this->unique_hash),
];
}
public function getValues($slug)
{
return $this->getCustomFieldValues($slug);
}
}

View File

@ -42,4 +42,11 @@ trait HasCustomFieldsTrait
$customFieldValue->save();
}
}
public function getCustomFieldValues($slug)
{
return $this->fields()->whereHas('customField', function ($query) use ($slug) {
$query->where('slug', $slug);
})->first();
}
}