@@ -41,23 +41,6 @@ class Person extends Model
4141 'tree_position_x ' ,
4242 'tree_position_y ' ,
4343 ];
44- // public function searchableAs()
45- // {
46- // return 'name';
47- // }
48-
49- /**
50- * The attributes that should be mutated to dates.
51- *
52- * @var array
53- */
54- protected $ casts = [
55- 'deleted_at ' => 'datetime ' ,
56- 'birthday ' => 'datetime ' ,
57- 'deathday ' => 'datetime ' ,
58- 'burial_day ' => 'datetime ' ,
59- 'chan ' => 'datetime ' ,
60- ];
6144
6245 protected $ guarded = ['id ' ];
6346
@@ -175,12 +158,12 @@ public function addEvent($title, $date, $place, $description = '')
175158
176159 public function birth ()
177160 {
178- return $ this ->events ->where ('title ' , '= ' , 'BIRT ' )->first ();
161+ return $ this ->dispatchesEvents ->where ('title ' , '= ' , 'BIRT ' )->first ();
179162 }
180163
181164 public function death ()
182165 {
183- return $ this ->events ->where ('title ' , '= ' , 'DEAT ' )->first ();
166+ return $ this ->dispatchesEvents ->where ('title ' , '= ' , 'DEAT ' )->first ();
184167 }
185168
186169 public function scopeWithBasicInfo ($ query )
@@ -202,4 +185,19 @@ public static function getBasicInfoCached($id)
202185 {
203186 return cache ()->remember ("person_basic_info_ {$ id }" , now ()->addHours (1 ), fn () => self ::withBasicInfo ()->find ($ id ));
204187 }
188+ /**
189+ * The attributes that should be mutated to dates.
190+ *
191+ * @return array
192+ */
193+ protected function casts (): array
194+ {
195+ return [
196+ 'deleted_at ' => 'datetime ' ,
197+ 'birthday ' => 'datetime ' ,
198+ 'deathday ' => 'datetime ' ,
199+ 'burial_day ' => 'datetime ' ,
200+ 'chan ' => 'datetime ' ,
201+ ];
202+ }
205203}
0 commit comments