PHP code example of oltrematica / laravel-parking-hub
1. Go to this page and download the library: Download oltrematica/laravel-parking-hub 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/ */
oltrematica / laravel-parking-hub example snippets
'drivers' => [
'easypark' => [
'class' => YourVendor\\LaravelEasyPark\\EasyParkValidator::class, // Replace with the actual validator class
'api_url' => env('EASYPARK_API_URL', 'https://cityname.parkinghub.net/restresources'),
'username' => env('EASYPARK_USERNAME'),
'password' => env('EASYPARK_PASSWORD'),
// other configuration options specific to EasyPark
],
'mycicero' => [
'class' => YourVendor\\LaravelMyCicero\\MyCiceroValidator::class, // Replace with the actual validator class
'username' => env('MYCICERO_USERNAME'),
'password' => env('MYCICERO_PASSWORD'),
'soap' => [
'endpoint' => env('MYCICERO_SOAP_ENDPOINT', 'https://cldweb.autobus.it/proxy.imomo/api/wsisosta_verifica'),
'namespace' => env('MYCICERO_SOAP_NAMESPACE', 'http://pluservice.net/ISosta'),
// ... other MyCicero specific SOAP settings
],
],
'parkeon' => [
'class' => Oltrematica\\ParkingHub\\Validators\\ParkeonValidator::class, // Example, replace with actual
'username' => env('PARKEON_USERNAME'),
'password' => env('PARKEON_PASSWORD'),
'endpoint' => env('PARKEON_ENDPOINT', 'https://parkeon.services/jlab/rest/1/pbs/getTransactions'),
// other configuration options specific to Parkeon
],
// Add other parking providers here
],
use Oltrematica\\ParkingHub\\Facades\\ParkingHub;
use Carbon\\Carbon;
// Check plate using the default driver
$response = ParkingHub::checkPlate('AA123BB', Carbon::now());
// Check plate using a specific driver
$responseEasypark = ParkingHub::driver('easypark')->checkPlate('AA123BB', Carbon::now());
$responseMyCicero = ParkingHub::driver('mycicero')->checkPlate('CC456DD', Carbon::now());
// The $response will be an instance of Oltrematica\ParkingHub\DTOs\ParkingValidationResponseData
if ($response->isValid) {
// Parking is valid
echo "Plate {$response->plate} parking is valid. Ends at: " . ($response->parkingEndTime ? $response->parkingEndTime->format('Y-m-d H:i:s') : 'N/A');
} else {
// Parking is not valid or an error occurred
echo "Plate {$response->plate} parking is not valid. Status: {$response->responseStatus->value}";
}
use Oltrematica\\ParkingHub\\Support\\Manager\\ParkingHubManager;
use Carbon\\Carbon;
// Resolve the manager
$parkingHubManager = app(ParkingHubManager::class);
// Check plate using the default driver
$response = $parkingHubManager->driver()->checkPlate('AA123BB', Carbon::now());
// Check plate using a specific driver
$responseParkeon = $parkingHubManager->driver('parkeon')->checkPlate('EE789FF', Carbon::now());
public function checkPlate(string $plateNumber, CarbonInterface $verificationDateTime): ParkingValidationResponseData
{
$requestTimestamp = now();
// Simulate an API call that finds a valid parking
$isValid = false; // Determine from API response
$parkingEndTime = null; // Determine from API response
$purchasedParkings = []; // Populate if provider returns multiple active parkings
$responseStatus = ProviderInteractionStatus::SUCCESS; // Set based on API interaction outcome
if ($plateNumber === 'VALID123') {
$isValid = true;
$parkingEndTime = $verificationDateTime->copy()->addHours(2);
$purchasedParkings[] = new \Oltrematica\ParkingHub\DTOs\PurchasedParkingData(
startDateTime: $verificationDateTime->copy()->subHour(),
endDateTime: $parkingEndTime
);
} elseif ($plateNumber === 'APIERROR') {
$responseStatus = ProviderInteractionStatus::ERROR_PROVIDER_SPECIFIC;
}
return new ParkingValidationResponseData(
responseStatus: $responseStatus,
plate: $plateNumber,
requestTimestamp: $requestTimestamp,
verificationTimestamp: $verificationDateTime,
isValid: $isValid,
parkingEndTime: $parkingEndTime,
purchasedParkings: $purchasedParkings
);
}