Edit File: FriendResource.php
<?php namespace App\Http\Resources\Api\Friend; use Illuminate\Http\Resources\Json\JsonResource; class FriendResource extends JsonResource { public function toArray($request) { // return the other user $otherUser = $this->user_id == auth()->id() ? $this->receiver : $this->sender; return [ 'id' => $this->id, 'user' => [ 'id' => $otherUser?->id, 'image' => $otherUser?->image, 'name' => $otherUser?->full_name, ], 'created_at' => $this->created_at->diffForHumans(), ]; } }
Back to File Manager