work in progress
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ChatResource extends BaseResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$data = parent::toArray($request);
|
||||
|
||||
if ($this->whenLoaded('messages')) {
|
||||
$data['messages'] = MessageResource::collection($this->messages);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,12 @@ class DynamicResource extends BaseResource
|
||||
if ($this->ledgers) {
|
||||
$result['ledgers'] = LedgerResource::collection($this->ledgers);
|
||||
}
|
||||
if ($this->participants) {
|
||||
if ($this->whenLoaded('participants')) {
|
||||
$result['participants'] = ParticipantResource::collection($this->participants);
|
||||
}
|
||||
if ($this->whenLoaded('chat')) {
|
||||
$result['chat'] = new ChatResource($this->chat);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ class LedgerResource extends BaseResource
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
$data = parent::toArray($request);
|
||||
|
||||
$data['mutations'] = MutationResource::collection($this->whenLoaded('mutations'));
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user