mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-26 07:53:58 +00:00
Vue Polling - Code sycn with fixes from Shipping Portal (dillon/51-vue-polling-experimental-1)
This commit is contained in:
@@ -14,15 +14,6 @@ use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
|
||||
class DocumentResource extends JsonResource
|
||||
{
|
||||
// protected $userInfo;
|
||||
|
||||
// public function userInfo($resource, $userInfo = null)
|
||||
// {
|
||||
// $this->userInfo = $userInfo;
|
||||
// }
|
||||
|
||||
private static $userInfo;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
@@ -31,23 +22,14 @@ class DocumentResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
//cief todo: remove
|
||||
// Log::error('DocumentResource 1: '. json_encode(self::$userInfo));
|
||||
// Log::error('DocumentResource 2: '. json_encode($this->relationLoaded('owner')));
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'reference' => $this->reference,
|
||||
'status' => (int) $this->status,
|
||||
'document_type' => $this->document_type,
|
||||
'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner, self::$userInfo) : new CompanyResource($this->owner, self::$userInfo)) : null,
|
||||
'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner, $this->userInfo) : new CompanyResource($this->owner, $this->userInfo)) : null,
|
||||
'files' => FileResource::collection($this->files),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
}
|
||||
|
||||
public static function customResourceCollection($resource, $userInfo): AnonymousResourceCollection
|
||||
{
|
||||
self::$userInfo = $userInfo;
|
||||
return parent::collection($resource);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user