code: public function uploadFile(int $id, UploadRequest $request, UploadService $uploadService)
      {
          if(!$object = $this->repository->find($id)) {
              abort(404);
          }
  
          $file = $request->file('file');
  
          $media = $uploadService->upload($object, $file);
  
          \Cache::tags('response')->flush();
  
          return new MediaResource($media);
      }
docs: Upload file
  
  @param int $id
  @param UploadRequest $request
  @param UploadService $uploadService
  @return MediaResource