Skip to content

Commit

Permalink
add audio support url
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonoryza committed Mar 14, 2024
1 parent 2053eb6 commit 46e8772
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Laravel Prayertime
# Laravel Quran

## install

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "laravel package to get quran data from some sources",
"type": "library",
"license": "MIT",
"version": "0.0.1",
"version": "0.0.2",
"autoload": {
"psr-4": {
"Jhonoryza\\LaravelQuran\\": "src/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function up(): void
$table->text('kitabah');
$table->text('latin');
$table->text('translation');
$table->string('audio_url');

$table->unique(['quran_id', 'ayah']);

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/QuranSyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function handle(QuranInterface $quran): void

protected function getPreferences(): array
{
$listSurah = Quran::query()->pluck('transliteration', 'external_id');
$listSurah = Quran::query()->pluck('external_id', 'external_id');
if ($listSurah->isNotEmpty()) {
$surahTransliteration = suggest(
label: 'want to select Surah ?',
Expand Down
1 change: 1 addition & 0 deletions src/Models/QuranVerse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class QuranVerse extends Model
'kitabah',
'latin',
'translation',
'audio_url',
];

protected $casts = [
Expand Down
2 changes: 2 additions & 0 deletions src/Support/Concerns/QuranInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface QuranInterface
public function getListSurah(): array;

public function getListVerses(int $surahId): array;

public function getAudioUrl(int $surahId, int $ayah): string;
}
8 changes: 8 additions & 0 deletions src/Support/QuranKemenag.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ public function getListVerses(int $surahId): array
'kitabah' => $item['kitabah'],
'latin' => $item['latin'],
'translation' => $item['translation'],
'audio_url' => $this->getAudioUrl($surahId, $item['ayah']),
];
}

return $verses;
}

public function getAudioUrl(int $surahId, int $ayah): string
{
$file = sprintf('%03d%03d', $surahId, $ayah);

return config('quran.audio_base_uri').$file.'.m4a';
}
}

0 comments on commit 46e8772

Please sign in to comment.