divino11/laravel-playtomic 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

divino11/laravel-playtomic

Composer 安装命令:

composer require divino11/laravel-playtomic

包简介

Laravel SDK for the Playtomic API — venue search, court availability, booking, and authentication.

README 文档

README

A Laravel SDK for the Playtomic API — venue search, court availability, booking, and authentication.

Installation

composer require divino11/laravel-playtomic

Laravel will auto-discover the service provider. To publish the configuration file:

php artisan vendor:publish --tag=playtomic-config

Configuration

Set the following environment variables (all optional — sensible defaults are provided):

Variable Default Description
PLAYTOMIC_BASE_URL https://api.playtomic.io/v1 API base URL
PLAYTOMIC_TIMEOUT 15 HTTP timeout in seconds
PLAYTOMIC_DEFAULT_RADIUS 50000 Venue search radius in meters

Usage

Search Venues

use Divino11\Playtomic\Contracts\PlaytomicClientInterface;

$client = app(PlaytomicClientInterface::class);
$venues = $client->searchVenues(40.4168, -3.7038, 50000);

Check Availability

$slots = $client->getAvailability('tenant-id', '2026-02-10');

Authentication (for bookings)

use Divino11\Playtomic\Contracts\PlaytomicAuthClientInterface;

$authClient = app(PlaytomicAuthClientInterface::class);
$tokens = $authClient->login('user@example.com', 'password');

High-Level Service

use Divino11\Playtomic\Services\PlaytomicService;

$service = app(PlaytomicService::class);

// Search by location name (geocodes automatically)
$venues = $service->searchVenuesByLocation('Madrid');

// Get availability grouped by time slot
$grouped = $service->getGroupedAvailability('tenant-id', '2026-02-10');

Book a Court

Booking requires authentication. The flow is: create → update → confirm a payment intent.

use Divino11\Playtomic\Contracts\PlaytomicAuthClientInterface;
use Divino11\Playtomic\DataTransferObjects\BookingRequestDto;

$authClient = app(PlaytomicAuthClientInterface::class);
$tokens = $authClient->login('user@example.com', 'password');

// 1. Create a payment intent
$request = new BookingRequestDto(
    tenantId: 'tenant-uuid',
    resourceId: 'court-resource-uuid',
    date: '2026-02-10',
    startTime: '10:00',
    duration: 90,           // minutes
    numberOfPlayers: 4,     // optional, defaults to 4
);

$paymentIntent = $authClient->createPaymentIntent(
    $tokens->accessToken,
    $request,
    $tokens->userId,
);

// 2. Update with payment method
$authClient->updatePaymentIntent(
    $tokens->accessToken,
    $paymentIntent->paymentIntentId,
    'WALLET',  // payment method
);

// 3. Confirm the booking
$result = $authClient->confirmPaymentIntent(
    $tokens->accessToken,
    $paymentIntent->paymentIntentId,
);

// $result is a BookingResultDto with: matchId, status, courtName, startDate, startTime, duration, price

Get User Bookings

$bookings = $authClient->getUserMatches(
    $tokens->accessToken,
    $tokens->userId,
    size: 50,                    // optional, defaults to 50
    sort: 'start_date,DESC',    // optional
);

// Each booking is a UserBookingDto with: matchId, startDate, endDate, status, resourceName, price, tenantName, tenantCity

Cancel a Booking

// Cancel with default reason ('PERSONAL')
$authClient->cancelBooking($tokens->accessToken, 'match-id');

// Cancel with a specific reason code
$authClient->cancelBooking($tokens->accessToken, 'match-id', 'CANCELED_BY_OWNER');

Book Multiple Courts

Book several courts at once with automatic rollback if any booking fails:

use Divino11\Playtomic\Contracts\PlaytomicAuthClientInterface;
use Divino11\Playtomic\DataTransferObjects\BookingRequestDto;

$authClient = app(PlaytomicAuthClientInterface::class);
$tokens = $authClient->login('user@example.com', 'password');

$requests = [
    new BookingRequestDto('tenant-uuid', 'court-1-uuid', '2026-02-10', '10:00', 90),
    new BookingRequestDto('tenant-uuid', 'court-2-uuid', '2026-02-10', '10:00', 90),
    new BookingRequestDto('tenant-uuid', 'court-3-uuid', '2026-02-10', '10:00', 90),
];

// Books each court sequentially, cancels all if one fails
$result = $authClient->bookMultipleCourts(
    $tokens->accessToken,
    $requests,
    $tokens->userId,
    rollbackOnFailure: true, // set to false to keep successful bookings even if one fails
);

// $result is a MultiBookingResultDto
$result->allSucceeded;  // bool
$result->successful;    // BookingResultDto[]
$result->failed;        // BookingRequestDto[]

Testing

composer test

License

MIT

divino11/laravel-playtomic 适用场景与选型建议

divino11/laravel-playtomic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 122 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「laravel」 「booking」 「playtomic」 「padel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 divino11/laravel-playtomic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 divino11/laravel-playtomic 我们能提供哪些服务?
定制开发 / 二次开发

基于 divino11/laravel-playtomic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 122
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-09