@@ 6-38 (lines=33) @@ | ||
3 | ||
4 | use \Carbon\Carbon; |
|
5 | ||
6 | final class UserSchemaExtended extends BaseSchema |
|
7 | { |
|
8 | protected $resourceType = 'user'; |
|
9 | ||
10 | public function getId($user) |
|
11 | { |
|
12 | return $user->id; |
|
13 | } |
|
14 | ||
15 | public function getAttributes($user) |
|
16 | { |
|
17 | return [ |
|
18 | 'full_name' => $user->full_name, |
|
19 | 'email' => $user->email, |
|
20 | 'role_id' => (int)$user->role_id, |
|
21 | 'created_at' => Carbon::parse($user->created_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
|
22 | 'updated_at' => Carbon::parse($user->updated_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
|
23 | 'created_by' => $user->created_by, |
|
24 | 'updated_by' => $user->updated_by, |
|
25 | 'status' => $user->status, |
|
26 | 'extendField' => 'Only admin', |
|
27 | ]; |
|
28 | } |
|
29 | ||
30 | public function getRelationships($user, $isPrimary, array $includeList) |
|
31 | { |
|
32 | return [ |
|
33 | 'role' => [ |
|
34 | self::DATA => $user->role, |
|
35 | ], |
|
36 | ]; |
|
37 | } |
|
38 | } |
|
39 |
@@ 302-333 (lines=32) @@ | ||
299 | * @apiUse StandardErrors |
|
300 | */ |
|
301 | ||
302 | final class UserSchema extends BaseSchema |
|
303 | { |
|
304 | protected $resourceType = 'user'; |
|
305 | ||
306 | public function getId($user) |
|
307 | { |
|
308 | return $user->id; |
|
309 | } |
|
310 | ||
311 | public function getAttributes($user) |
|
312 | { |
|
313 | return [ |
|
314 | 'full_name' => $user->full_name, |
|
315 | 'email' => $user->email, |
|
316 | 'role_id' => (int)$user->role_id, |
|
317 | 'created_at' => Carbon::parse($user->created_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
|
318 | 'updated_at' => Carbon::parse($user->updated_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
|
319 | 'created_by' => $user->created_by, |
|
320 | 'updated_by' => $user->updated_by, |
|
321 | 'status' => $user->status, |
|
322 | ]; |
|
323 | } |
|
324 | ||
325 | public function getRelationships($user, $isPrimary, array $includeList) |
|
326 | { |
|
327 | return [ |
|
328 | 'role' => [ |
|
329 | self::DATA => $user->role, |
|
330 | ], |
|
331 | ]; |
|
332 | } |
|
333 | } |
|
334 |