Files
citrus/database/seeders/AwardSeeder.php
T

101 lines
4.9 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\Award;
use Illuminate\Database\Seeder;
class AwardSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$awards = [
[
'title' => 'Here & AWS & THY Hackathon Birinciliği',
'description' => '21 Mart 2019 yılında Here, Amazon Web Services (AWS) ve Türk Hava Yolları\'nın (THY) ortaklaşa yürüttüğü Hackathon kapsamında büyük bir başarı göstererek 1. lik ödülünü almaya hak kazandık.',
'issuer' => 'Here & AWS & THY',
'award_date' => '2019-03-21',
'image' => 'assets/img/awards/truncgil-hackathon-birincisi-here-aws-thy.png',
'external_link' => 'https://truncgil.com',
'is_featured' => true,
'is_active' => true,
'sort_order' => 1,
'category' => 'hackathon',
'translations' => [
'en' => [
'title' => 'Here & AWS & THY Hackathon First Place',
'description' => 'On March 21, 2019, we achieved outstanding success and won the 1st place award in the Hackathon jointly organized by Here, Amazon Web Services (AWS), and Turkish Airlines (THY).',
'issuer' => 'Here, AWS & Turkish Airlines',
]
],
],
[
'title' => 'Gaziantep Teknopark Yılın İhracat Ödülü',
'description' => 'İhracat faaliyetlerindeki üstün başarımızdan ötürü 26 Aralık 2019 yılında Gaziantep Teknopark tarafından "Yılın İhracat Ödülü"ne layık görüldük.',
'issuer' => 'Gaziantep Teknopark',
'award_date' => '2019-12-26',
'image' => 'assets/img/awards/truncgil-teknoloji-yilin-ihracat-odulu.png',
'external_link' => 'https://truncgil.com',
'is_featured' => true,
'is_active' => true,
'sort_order' => 2,
'category' => 'export',
'translations' => [
'en' => [
'title' => 'Gaziantep Technopark Export of the Year Award',
'description' => 'Due to our outstanding achievements in export activities, we were deemed worthy of the "Export of the Year Award" by Gaziantep Technopark on December 26, 2019.',
'issuer' => 'Gaziantep Technopark',
]
],
],
[
'title' => 'HackSmarCity Hackathon Birinciliği',
'description' => 'Gaziantep Teknopark, Target Teknoloji Transfer Ofisi, Gaziantep Büyükşehir Belediyesi ve Gaziantep Bilişim\'in ortaklaşa düzenlediği akıllı şehir çözümleri temalı HackSmarCity Hackathon\'unda 1. lik elde ettik.',
'issuer' => 'Gaziantep Büyükşehir Belediyesi & Teknopark',
'award_date' => '2019-11-15', // Approximate date in 2019/2020
'image' => 'assets/img/awards/truncgil-teknoloji-hacksmarcity.jpg',
'external_link' => 'https://truncgil.com',
'is_featured' => false,
'is_active' => true,
'sort_order' => 3,
'category' => 'hackathon',
'translations' => [
'en' => [
'title' => 'HackSmarCity Hackathon First Place',
'description' => 'We achieved 1st place in the HackSmarCity Hackathon themed around smart city solutions, jointly organized by Gaziantep Technopark, Target Technology Transfer Office, Gaziantep Metropolitan Municipality, and Gaziantep Bilisim.',
'issuer' => 'Gaziantep Metropolitan Municipality & Technopark',
]
],
],
];
foreach ($awards as $awardData) {
$translations = $awardData['translations'] ?? [];
unset($awardData['translations']);
$award = Award::updateOrCreate(
[
'award_date' => $awardData['award_date'],
'image' => $awardData['image'],
],
$awardData
);
// Save default (Turkish) translations in translation table too so HasTranslations resolves correctly
$award->setTranslation('title', 'tr', $awardData['title'], 'published');
$award->setTranslation('description', 'tr', $awardData['description'], 'published');
$award->setTranslation('issuer', 'tr', $awardData['issuer'], 'published');
// Save English translations
foreach ($translations as $langCode => $fields) {
foreach ($fields as $fieldName => $value) {
$award->setTranslation($fieldName, $langCode, $value, 'published');
}
}
}
}
}