Edit File: PlanResource.php
<?php namespace App\Http\Resources; use Carbon\Carbon; use App\Models\Subscription; use Illuminate\Http\Resources\Json\JsonResource; class PlanResource extends JsonResource { /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable */ public function toArray($request) { $user = auth()->user(); if($subscription = Subscription::where('user_id' , $user->id)->where('unsupscribe' , '0')->where('plan_id' , $this->id)->where('end_at', '>', Carbon::now())->first()) { $status = true; }else{ $status = false; } return [ 'id' => $this->id ?? '', 'name'=>$this->name ?? '', 'price'=>$this->price ?? '', 'logo'=>$this->LogoPath ?? '', 'description'=>$this->description ?? '', 'subscribed' => $status, 'expire_date' => $subscription->end_at ?? '', ]; } }
Back to File Manager