Repository: statamic-rad-pack/runway (php)

Issue:
Computed fields not displaying in the front end
### Discussed in https://github.com/statamic-rad-pack/runway/discussions/403

<div type='discussions-op-text'>

<sup>Originally posted by **mefenlon** January 15, 2024</sup>
I just upgraded from v5 to v6. I am now having issues with the computed fields displaying in the front end.
Using the dosumentation, https://runway.duncanmcclean.com/blueprints#content-computed-fields, I have an attribute defined in my model. On the backend, the blueprint is configured as computed and it displays just fine.
In my Model
```
    public function fullName(): Attribute
    {
        return Attribute::make(
            get: function () {
                return "{$this->display_title} {$this->sort_title}";
            }
        );
    }
```
In my blueprint
```
          -
            handle: full_name
            field:
              input_type: text
              antlers: false
              type: text
              display: Title
              icon: text
              listable: hidden
              instructions_position: above
              visibility: computed
              replicator_preview: true
              duplicate: false
              hide_display: false
```
In the front end, I am unable to list the attribute.
show.antlers.html
```
    {{ sort_title }} displays fine |
    {{ display_title }} displays fine |
    {{ full_name }} nothing
```</div>

Pull request:
[6.x] Fix model accessors not being augmented
This pull request fixes an issue where model accessors aren't being augmented after the augmentation changes in #354.

Fixes #404.

Patch:
diff --git a/src/Data/AugmentedModel.php b/src/Data/AugmentedModel.php
index bd2bcf7..e618190 100644
--- a/src/Data/AugmentedModel.php
+++ b/src/Data/AugmentedModel.php
@@ -2,6 +2,7 @@
 
 namespace StatamicRadPack\Runway\Data;
 
+use Illuminate\Database\Eloquent\Casts\Attribute;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Str;
 use Statamic\Data\AbstractAugmented;
@@ -133,6 +134,10 @@ class AugmentedModel extends AbstractAugmented
                 ->toArray();
         }
 
+        if ($value instanceof Attribute) {
+            $value = ($value->get)();
+        }
+
         return new Value(
             $value,
             $handle,


Test patch:
diff --git a/tests/Data/AugmentedModelTest.php b/tests/Data/AugmentedModelTest.php
index 43c654c..e61fe99 100644
--- a/tests/Data/AugmentedModelTest.php
+++ b/tests/Data/AugmentedModelTest.php
@@ -60,4 +60,14 @@ class AugmentedModelTest extends TestCase
         $this->assertEquals('Alternative Title...', $augmented->get('values')->value()['alt_title']->value());
         $this->assertEquals('<p>This is a <strong>great</strong> post! You should <em>read</em> it.</p>', trim($augmented->get('values')->value()['alt_body']->value()));
     }
+
+    /** @test */
+    public function it_gets_value_from_model_accessor()
+    {
+        $post = Post::factory()->create();
+
+        $augmented = new AugmentedModel($post);
+
+        $this->assertEquals('This is an excerpt.', $augmented->get('excerpt')->value());
+    }
 }
diff --git a/tests/__fixtures__/app/Models/Post.php b/tests/__fixtures__/app/Models/Post.php
index 2aec82f..3dad5f1 100644
--- a/tests/__fixtures__/app/Models/Post.php
+++ b/tests/__fixtures__/app/Models/Post.php
@@ -2,6 +2,7 @@
 
 namespace StatamicRadPack\Runway\Tests\Fixtures\Models;
 
+use Illuminate\Database\Eloquent\Casts\Attribute;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use StatamicRadPack\Runway\Routing\Traits\RunwayRoutes;
@@ -42,9 +43,13 @@ class Post extends Model
         return $this->belongsTo(Author::class);
     }
 
-    public function getExcerptAttribute()
+    public function excerpt(): Attribute
     {
-        return 'This is an excerpt.';
+        return Attribute::make(
+            get: function () {
+                return 'This is an excerpt.';
+            }
+        );
     }
 
     protected static function newFactory()