PHP code example of jhonoryza / laravel-prayertime

1. Go to this page and download the library: Download jhonoryza/laravel-prayertime 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/ */

    

jhonoryza / laravel-prayertime example snippets


public function getPrayerTimes(string $provinceId, string $cityId, int $month, int $year): array



Route::get('/time', function (PrayerTime $prayer) {
    $prayerTimes = $prayer->getPrayerTimes(
        provinceId: '', // Kab Bandung province external id for manual calculation or when using kemenag use this c20ad4d76fe97759aa27a0c99bff6710
        cityId: '3204', // Kab Bandung external id for manual calculation or when using kemenag use this 0777d5c17d4066b82ab86dff8a46af6f
        month: 6,
        year: 2024
    );
    foreach ($prayerTimes as $index => $times) {
        foreach ($times as $key => $prayerTime) {
            if (in_array($key, ['city_external_id', 'prayer_at'])) {
                continue;
            }
            $times[$key] = $prayerTime->format('H:i');
        }

        $prayerTimes[$index] = $times;
    }

    return response()->json([
        'data' => $prayerTimes,
    ]);
});
bash
php artisan migrate
bash
php artisan vendor:publish --tag=prayertime-config
bash
php artisan pray:sync-city