Files
citrus/database/seeders/FinanceProductSeeder.php
T

169 lines
8.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Database\Seeders;
use App\Models\Product;
use App\Models\ProductCategory;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class FinanceProductSeeder extends Seeder
{
public function run(): void
{
// 1. Download the logo from https://finance.truncgil.com/img/logo.svg
$logoUrl = 'https://finance.truncgil.com/img/logo.svg';
$logoFileName = 'products/truncgil-finance-logo.svg';
try {
// Check if directory exists in the public disk
if (!Storage::disk('public')->exists('products')) {
Storage::disk('public')->makeDirectory('products');
}
// Get logo contents
$context = stream_context_create([
"ssl" => [
"verify_peer" => false,
"verify_peer_name" => false,
],
"http" => [
"header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)\r\n"
]
]);
$logoContents = file_get_contents($logoUrl, false, $context);
if ($logoContents !== false) {
Storage::disk('public')->put($logoFileName, $logoContents);
$this->command?->info('Downloaded and stored the Trunçgil Finance logo successfully.');
} else {
$this->command?->error('Could not download logo contents.');
}
} catch (\Exception $e) {
$this->command?->error('Failed to download Trunçgil Finance logo: ' . $e->getMessage());
}
// 2. Prepare translatable fields
$title = [
'tr' => 'Trunçgil Finance (Canlı Döviz, Altın ve Kripto Para API Servisi)',
'en' => 'Trunçgil Finance (Live Currency, Gold, and Crypto API Service)',
];
$content = [
'tr' => 'Trunçgil Finance, altın, döviz ve kripto para verilerini anlık ve gecikmesiz olarak sunan yüksek performanslı bir API servisidir. Kurumsal uygulamalarınızdan mobil projelerinize kadar her ölçekte güvenle entegre edebilirsiniz.',
'en' => 'Trunçgil Finance is a high-performance API service offering instantaneous and lag-free gold, currency, and cryptocurrency data. Securely integrate into your projects of any scale, from enterprise apps to mobile platforms.',
];
// 3. Prepare detailed landing page data structure
$landingPageData = [
'hero' => [
'slogan_tr' => 'Yüksek Performanslı Altın, Döviz ve Kripto API Servisi',
'slogan_en' => 'High-Performance Gold, Currency, and Crypto API Service',
'sub_slogan_tr' => 'Anlık finansal verileri, güçlü altyapımızla projelerinize gecikmesiz entegre edin. Geliştirici dostu entegrasyon ve sıfır kesinti.',
'sub_slogan_en' => 'Integrate real-time financial data into your applications lag-free with our robust infrastructure. Developer-friendly and 100% uptime.',
'featured_image' => $logoFileName,
],
'features' => [
[
'title_tr' => 'Gecikmesiz Canlı Akış',
'title_en' => 'Lag-Free Live Streams',
'icon' => 'processor',
],
[
'title_tr' => 'Geliştirici Dostu SDK & API',
'title_en' => 'Developer-Friendly SDK & API',
'icon' => 'crop',
],
[
'title_tr' => 'Güvenli ve Kesintisiz Servis',
'title_en' => 'Secure & Uptime Gurantee',
'icon' => 'safe',
],
[
'title_tr' => 'Zengin Veri Kaynakları',
'title_en' => 'Rich Data Sources',
'icon' => 'cloud',
],
],
'how_it_works' => [
'download_form_label_tr' => 'Nasıl Entegre Edilir?',
'download_form_label_en' => 'How to Integrate?',
'steps' => [
[
'number' => 1,
'title_tr' => 'API Anahtarınızı Alın',
'title_en' => 'Get Your API Key',
'description_tr' => 'Saniyeler içinde kayıt olun ve size özel güvenli API anahtarınızı oluşturun.',
'description_en' => 'Sign up in seconds and generate your secure, dedicated API key.',
],
[
'number' => 2,
'title_tr' => 'Dokümantasyonu İnceleyin',
'title_en' => 'Browse Documentation',
'description_tr' => 'Her dilde hazırlanmış örnek kodlar ve şemalarla entegrasyon adımlarını inceleyin.',
'description_en' => 'Check integration steps with sample codes and schemas available in every language.',
],
[
'number' => 3,
'title_tr' => 'Kodunuza Dahil Edin',
'title_en' => 'Integrate Into Code',
'description_tr' => 'Hazır kütüphanelerimizle veya RESTful uç noktalarımızla verileri projenize çekin.',
'description_en' => 'Fetch data using our client SDKs or standard RESTful HTTP endpoints.',
],
[
'number' => 4,
'title_tr' => 'Canlıya Alın & İzleyin',
'title_en' => 'Go Live & Monitor',
'description_tr' => 'Kullanım istatistiklerinizi panelimizden izleyin ve yüksek hızın tadını çıkarın.',
'description_en' => 'Track your request statistics in real-time from the dashboard and enjoy lightning speed.',
],
],
],
'faqs' => [
[
'question_tr' => 'Veriler ne sıklıkla güncelleniyor?',
'question_en' => 'How frequently is the data updated?',
'answer_tr' => 'Finansal verilerimiz doğrudan global ve yerel borsalardan anlık akış olarak alınmakta ve milisaniyeler bazında güncellenmektedir.',
'answer_en' => 'Our financial feeds are retrieved directly from global and regional exchanges and updated in real-time on a millisecond scale.',
],
[
'question_tr' => 'Ücretsiz deneme sürümü mevcut mu?',
'question_en' => 'Is there a free tier available?',
'answer_tr' => 'Evet. Trunçgil Finance geliştiriciler için belirli sayıda aylık istek limitine sahip tamamen ücretsiz bir sandbox planı sunmaktadır.',
'answer_en' => 'Yes. Trunçgil Finance offers a completely free sandbox tier with a monthly request allowance for developers to test and build.',
],
[
'question_tr' => 'Hangi veri türlerini sunuyorsunuz?',
'question_en' => 'What kinds of financial data do you offer?',
'answer_tr' => 'Uluslararası döviz pariteleri, serbest piyasa ve banka altın fiyatları, kıymetli madenler ve tüm popüler kripto para birimleri veri setlerimizin parçasıdır.',
'answer_en' => 'Global currency exchange rates, free-market and banking gold values, precious metals, and all major cryptocurrency pairs are fully covered.',
],
],
];
// 4. Determine category
$category = ProductCategory::first();
$categoryId = $category ? $category->id : 1;
// 5. Update or Create the Product
Product::updateOrCreate(
['slug' => 'truncgil-finance'],
[
'product_category_id' => $categoryId,
'title' => $title,
'type' => 'product',
'hero_image' => $logoFileName,
'content' => $content,
'landing_page_data' => $landingPageData,
'view_template' => 'front.products.finance',
'external_url' => 'https://finance.truncgil.com/',
'sort_order' => 2,
'is_active' => true,
]
);
$this->command?->info('✅ Trunçgil Finance product seeded successfully!');
}
}