mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Helper for custom field to get by slug
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user