getFirebaseJsonPath(); $factory = (new Factory) ->withServiceAccount($firebaseFile); $push = $factory->createMessaging(); $message = CloudMessage::fromArray([ 'token' => $this->user->packageNames()->where('package_names.id', $this->packageName->id)->first()->pivot->fcm_token, 'notification' => [ 'title' => $this->title, 'body' => $this->description, ], 'data' => $this->data ]); $push->send($message); } /** * Get Firebase JSON file path from Media Library for the package. */ private function getFirebaseJsonPath(): ?string { $media = $this->packageName->getFirstMedia('firebase_json'); if (!$media) { return null; } return $media->getPath(); } }