File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php namespace Octobro \API \Transformers ;
2+
3+ use RainLab \User \Models \UserGroup ;
4+ use Octobro \API \Classes \Transformer ;
5+
6+ class UserGroupTransformer extends Transformer
7+ {
8+ public function data (UserGroup $ userGroup )
9+ {
10+ return [
11+ 'id ' => (int ) $ userGroup ->id ,
12+ 'name ' => $ userGroup ->name ,
13+ 'code ' => $ userGroup ->code ,
14+ 'description ' => $ userGroup ->description ,
15+ ];
16+ }
17+ }
Original file line number Diff line number Diff line change 55
66class UserTransformer extends Transformer
77{
8+ public $ availableIncludes = [
9+ 'groups ' ,
10+ ];
11+
812 public function data (User $ user )
913 {
1014 return [
@@ -17,4 +21,9 @@ public function data(User $user)
1721 ];
1822 }
1923
24+ public function includeGroups (User $ user )
25+ {
26+ return $ this ->collection ($ user ->groups , new UserGroupTransformer );
27+ }
28+
2029}
You can’t perform that action at this time.
0 commit comments