Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| UserLogResource | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\User\Resources; |
| 4 | |
| 5 | use Carbon\Carbon; |
| 6 | |
| 7 | use Illuminate\Http\Request; |
| 8 | use Illuminate\Http\Resources\Json\JsonResource; |
| 9 | |
| 10 | /** |
| 11 | * @property int $id |
| 12 | * @property int $target_user_id |
| 13 | * @property int $actor_user_id |
| 14 | * @property int $operation |
| 15 | * @property Carbon|null $created_at |
| 16 | * @property array $detail |
| 17 | */ |
| 18 | class UserLogResource extends JsonResource |
| 19 | { |
| 20 | public function toArray(Request $request): array |
| 21 | { |
| 22 | return [ |
| 23 | 'id' => $this->id, |
| 24 | 'target_user_id' => $this->target_user_id, |
| 25 | 'actor_user' => new UserResource($this->whenLoaded('actorUser')), |
| 26 | 'operation' => $this->operation, |
| 27 | 'detail' => $this->detail, |
| 28 | 'created_at' => $this->created_at?->toIso8601String(), |
| 29 | ]; |
| 30 | } |
| 31 | } |