File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 227
227
expect ($ this ->getLastActivity ()->description )->toEqual ($ expectedDescription );
228
228
});
229
229
230
- it ('can replace the placeholders deeply ' , function () {
231
- $ article = Article::create (['name ' => 'article name ' ]);
230
+ it ('can replace the placeholders with object properties and accessors ' , function () {
231
+ $ article = Article::create ([
232
+ 'name ' => 'article name ' ,
233
+ 'user_id ' => User::first ()->id
234
+ ]);
232
235
233
236
$ article ->foo = new stdClass ();
234
237
$ article ->foo ->bar = new stdClass ();
237
240
activity ()
238
241
->performedOn ($ article )
239
242
->withProperties (['key ' => 'value ' , 'key2 ' => ['subkey ' => 'subvalue ' ]])
240
- ->log ('Subject name is :subject.name, deeply nested property is :subject.foo.bar.baz ' );
243
+ ->log ('Subject name is :subject.name, deeply nested property is :subject.foo.bar.baz, accessor property is :subject.owner_name ' );
241
244
242
- $ expectedDescription = 'Subject name is article name, deeply nested property is zal ' ;
245
+ $ expectedDescription = 'Subject name is article name, deeply nested property is zal, accessor property is name 1 ' ;
243
246
244
247
expect ($ this ->getLastActivity ()->description )->toEqual ($ expectedDescription );
245
248
});
Original file line number Diff line number Diff line change @@ -10,8 +10,13 @@ class Article extends Model
10
10
11
11
protected $ guarded = [];
12
12
13
- public function User ()
13
+ public function user ()
14
14
{
15
15
return $ this ->belongsTo (User::class);
16
16
}
17
+
18
+ public function getOwnerNameAttribute ()
19
+ {
20
+ return $ this ->user ?->name;
21
+ }
17
22
}
You can’t perform that action at this time.
0 commit comments