PHP code example of carshub / carshub-connector

1. Go to this page and download the library: Download carshub/carshub-connector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

carshub / carshub-connector example snippets


use CarsHub\Connector\Facades\CarsHub;

// All six page configurations in one call — use this in your layout/middleware
// to determine which pages are enabled and what their titles/settings are.
// Keys: home, about, crew_list, events, event_detail, contact
$allPages = CarsHub::pages();

// Or fetch a single page by key (useful for page-level controllers)
$home = CarsHub::page('home');

// Upcoming and past events (list — id, title, location, starts_at, ends_at, avatar_url, banner_url)
$upcoming = CarsHub::events('upcoming');
$past     = CarsHub::events('past');

// Full event detail including the attendee list (attending + maybe)
$detail = CarsHub::eventDetail(3);
// $detail['attendees']         — list of attendees; every entry _by_day has the same shape as attendees[] above (per-day cars/is_passenger)

// Crew member roster (id, name, username, avatar_url, role, staff_title, joined_at, social_links)
// social_links: {instagram, facebook, x, snapchat, website} — null when not set
$members = CarsHub::members();

// All active cars owned by crew members (

use CarsHub\Connector\Facades\CarsHub;
use CarsHub\Connector\Exceptions\CarsHubApiException;

try {
    // Create a new event — returns the created event array
    $event = CarsHub::createEvent([
        'title'        => 'Silvia Cup Round 1',
        'description'  => 'First round of the Nissan Silvia one-make series.',
        'location'     => 'Circuit Zandvoort',
        'address'      => 'Burgemeester van Alphenstraat 108, Zandvoort',
        'starts_at'    => '2026-08-15T09:00:00Z',
        'ends_at'      => '2026-08-15T17:00:00Z',
        'members_only' => false,
        'invite_only'  => false,
    ]);
    $eventId = $event['id'];

    // Update an existing event (replaces all fields)
    $updated = CarsHub::updateEvent($eventId, [
        'title'     => 'Silvia Cup Round 1 — Updated',
        'starts_at' => '2026-08-15T09:00:00Z',
        'ends_at'   => '2026-08-15T18:00:00Z',
    ]);

    // Delete an event permanently
    CarsHub::deleteEvent($eventId);
} catch (CarsHubApiException $e) {
    // Log or surface the error as appropriate for your application
    logger()->error('CarsHub event import failed: ' . $e->getMessage());
}
bash
php artisan vendor:publish --tag=carshub-config