Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit 5bb7348

Browse files
committed
Add url attribute decorator
1 parent e0a2e9d commit 5bb7348

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/AdvancedCustomFields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait AdvancedCustomFields
1616
*
1717
* @return \Illuminate\Support\Collection
1818
*/
19-
public function getFieldsAttribute($fields)
19+
public function getFieldsAttribute($fields = null)
2020
{
2121
if (count($this->fields)) {
2222
return $this->fields;

src/Modest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class Modest implements ArrayAccess, JsonSerializable
4949
*/
5050
protected $attributes;
5151

52+
/**
53+
* @var null|string
54+
*/
55+
protected $url;
56+
5257
/**
5358
* Create a new instance
5459
*
@@ -196,6 +201,18 @@ public function getExcerptAttribute($excerpt)
196201
return $excerpt ?: content_to_excerpt($this->content, $this->excerptLength);
197202
}
198203

204+
/**
205+
* Url attribute getter
206+
*
207+
* @param null $url
208+
*
209+
* @return string
210+
*/
211+
public function getUrlAttribute($url = null)
212+
{
213+
return $this->url ?: $this->url = get_permalink($this->id);
214+
}
215+
199216
/**
200217
* Translates key name to attribute getter name
201218
*

0 commit comments

Comments
 (0)