File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ abstract class OneRoster extends Model
2323
2424 protected static $ collection ;
2525
26+
2627 /**
2728 * @return array
2829 */
@@ -35,8 +36,8 @@ protected static function generateHeader(): array
3536 }
3637
3738 return [
38- 'X-Requested-With ' => 'XMLHttpRequest ' ,
39- 'Authorization ' => "Bearer $ jwt "
39+ 'X-Requested-With ' => 'XMLHttpRequest ' ,
40+ 'Authorization ' => "Bearer $ jwt "
4041 ];
4142 }
4243
@@ -47,13 +48,24 @@ public static function find($id)
4748 return new static ((array )$ json );
4849 }
4950
51+ public static function getClassName (){
52+ return (new \ReflectionClass (get_called_class ()))->getShortName ();
53+ }
54+
55+ protected static function extract ($ object )
56+ {
57+ $ name = mb_strtolower (self ::getClassName ());
58+ return $ object ->$ name ;
59+ }
60+
5061 public static function all ()
5162 {
5263 $ header = self ::generateHeader ();
5364 $ json_array = OpenLRW::httpGet (self ::PREFIX . static ::$ collection , $ header );
5465 $ results = [];
5566 foreach ($ json_array as $ json ) {
56- $ results [] = new static ((array )$ json );
67+ $ object = self ::extract ($ json );
68+ $ results [] = new static ((array )$ object );;
5769 }
5870
5971 return $ results ;
You can’t perform that action at this time.
0 commit comments