diff --git a/app/Helpers/bibHelper.php b/app/Helpers/bibHelper.php index 122c100..20c3569 100644 --- a/app/Helpers/bibHelper.php +++ b/app/Helpers/bibHelper.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; +use Illuminate\Support\Facades\Http; function pre($object, $die = false) { @@ -581,8 +582,18 @@ if (!function_exists('NepaliMonthNameByNumber')) { function NepaliMonthNameByNumber($number) { $MonthNames = array( - "Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj", - "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra" + "Baisakh", + "Jestha", + "Ashad", + "Shrawan", + "Bhadra", + "Asoj", + "Kartik", + "Mangsir", + "Poush", + "Magh", + "Falgun", + "Chaitra" ); return $MonthNames[$number - 1]; } @@ -593,8 +604,18 @@ if (!function_exists('NepaliMonthName')) { { $Month = NepaliMonth($engDate); $MonthNames = array( - "Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj", - "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra" + "Baisakh", + "Jestha", + "Ashad", + "Shrawan", + "Bhadra", + "Asoj", + "Kartik", + "Mangsir", + "Poush", + "Magh", + "Falgun", + "Chaitra" ); return $MonthNames[$Month - 1]; } @@ -627,7 +648,7 @@ function pushScriptToFooter($script) } function sectionHeader($text, $sectiontitle = null) { - $texts=explode(" ",$text); + $texts = explode(" ", $text); ?>
@@ -636,7 +657,8 @@ function sectionHeader($text, $sectiontitle = null) -

+

@@ -648,14 +670,35 @@ if (!function_exists('replace_img_src')) { { return preg_replace( '/src="storage(\/[^"]*)"/', - 'src="'.site_url().'storage$1"', + 'src="' . site_url() . 'storage$1"', $content ); } } + +function fetchVideosByChannel($channelId) +{ + $url = 'https://www.googleapis.com/youtube/v3/search'; + + $response = Http::get($url, [ + 'key' => 'AIzaSyAtDLH9Xzi_Mg-bvz4H27lvqQpT7AR2Bo0', + 'channelId' => $channelId, + 'part' => 'snippet', + 'order' => 'date', + 'maxResults' => '8', + 'type' => 'video', + ]); + + if ($response->successful()) { + return $response->json()['items']; + } + + return []; +} + function processForShortcode($content) { - $content=replace_img_src($content); + $content = replace_img_src($content); return preg_replace_callback('/\[([\w_]+)([^]]*)\]/', function ($matches) { $shortcodeName = $matches[1]; $shortcodeAttributes = []; @@ -687,4 +730,4 @@ if (!function_exists('uploadImage')) { $filePath = Storage::disk('public')->putFileAs($path, $file, $fileName); return $filePath; } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/WebsiteController.php b/app/Http/Controllers/WebsiteController.php index 70ff51b..04f312f 100644 --- a/app/Http/Controllers/WebsiteController.php +++ b/app/Http/Controllers/WebsiteController.php @@ -27,6 +27,7 @@ use Illuminate\Http\Request; // Import the Request class use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\View; +use Illuminate\Support\Facades\Http; class WebsiteController extends Controller { @@ -43,7 +44,11 @@ class WebsiteController extends Controller public function home() { + $channelId = env('CHANNEL_ID'); + $videos = fetchVideosByChannel($channelId); + return view('landing.index', [ + 'videos' => $videos, 'banners' => Banners::get(), 'benefits' => Benefits::get(), 'success_stories' => Success_stories::get(), diff --git a/config/services.php b/config/services.php index 0ace530..ae93b2c 100644 --- a/config/services.php +++ b/config/services.php @@ -31,4 +31,8 @@ return [ 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], + 'youtube' => [ + 'api_key' => 'AIzaSyAtDLH9Xzi_Mg-bvz4H27lvqQpT7AR2Bo0', + ], + ]; diff --git a/resources/views/landing/index.blade.php b/resources/views/landing/index.blade.php index 9de89b6..bc1d67a 100644 --- a/resources/views/landing/index.blade.php +++ b/resources/views/landing/index.blade.php @@ -888,39 +888,27 @@
- @foreach ($success_stories as $story) -
-

- Trusted by Many — Testimonials -

-
+
+

+ Trusted by Many — Testimonials +

+
+ @foreach ($videos as $video) @php - function convertToEmbedUrl($url) - { - $parsed = parse_url($url); - if (isset($parsed['query'])) { - parse_str($parsed['query'], $queryParams); - if (isset($queryParams['v'])) { - return 'https://www.youtube.com/embed/' . $queryParams['v']; - } - } - return $url; // fallback - } + $videoId = $video['id']['videoId']; + $embedUrl = "https://www.youtube.com/embed/{$videoId}"; @endphp - - @foreach (json_decode($story->extra_content) as $content) -
-
- -
+
+
+
- @endforeach -
+
+ @endforeach
- @endforeach +