@@ -110,33 +110,18 @@ protected function castAttribute($key, $value)
110
110
return $ value ;
111
111
}
112
112
113
- switch ($ this ->getCastType ($ key )) {
114
- case 'int ' :
115
- case 'integer ' :
116
- return (int ) $ value ;
117
- case 'real ' :
118
- case 'float ' :
119
- case 'double ' :
120
- return (float ) $ value ;
121
- case 'string ' :
122
- return (string ) $ value ;
123
- case 'bool ' :
124
- case 'boolean ' :
125
- return (bool ) $ value ;
126
- case 'object ' :
127
- return $ this ->fromJson ($ value , true );
128
- case 'array ' :
129
- case 'json ' :
130
- return $ this ->fromJson ($ value );
131
- case 'date ' :
132
- return $ this ->asDate ($ value );
133
- case 'datetime ' :
134
- return $ this ->asDateTime ($ value );
135
- case 'timestamp ' :
136
- return $ this ->asTimestamp ($ value );
137
- default :
138
- return $ this ->asModel ($ key , $ value ) ?? $ value ;
139
- }
113
+ return match ($ this ->getCastType ($ key )) {
114
+ 'int ' , 'integer ' => (int ) $ value ,
115
+ 'real ' , 'float ' , 'double ' => (float ) $ value ,
116
+ 'string ' => (string ) $ value ,
117
+ 'bool ' , 'boolean ' => (bool ) $ value ,
118
+ 'object ' => $ this ->fromJson ($ value , true ),
119
+ 'array ' , 'json ' => $ this ->fromJson ($ value ),
120
+ 'date ' => $ this ->asDate ($ value ),
121
+ 'datetime ' => $ this ->asDateTime ($ value ),
122
+ 'timestamp ' => $ this ->asTimestamp ($ value ),
123
+ default => $ this ->asModel ($ key , $ value ) ?? $ value ,
124
+ };
140
125
}
141
126
142
127
/**
@@ -288,7 +273,7 @@ protected function getRelationshipFromMethod($method)
288
273
$ relation = $ this ->$ method ();
289
274
290
275
if (!$ relation instanceof RelationInterface) {
291
- throw new LogicException (get_class ( $ this ) .':: ' .$ method .' must return a relationship instance. ' );
276
+ throw new LogicException ($ this ::class .':: ' .$ method .' must return a relationship instance. ' );
292
277
}
293
278
294
279
$ results = $ relation ->getResults ();
0 commit comments