86 lines
5.3 KiB
PHP
86 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Setting\database\seeders;
|
|
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Modules\Setting\app\Models\Setting;
|
|
|
|
class SettingDatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$settings = [
|
|
//-- General setting
|
|
['setting_name' => 'general_setting', 'name' => 'company_name', 'detail' => 'Arogin'],
|
|
['setting_name' => 'general_setting', 'name' => 'address', 'detail' => 'Bhaktapur'],
|
|
['setting_name' => 'general_setting', 'name' => 'contact_number', 'detail' => '6600000'],
|
|
['setting_name' => 'general_setting', 'name' => 'mobile_number', 'detail' => '9800000000'],
|
|
['setting_name' => 'general_setting', 'name' => 'alt_mobile_number', 'detail' => '9700000000'],
|
|
['setting_name' => 'general_setting', 'name' => 'info_email_address', 'detail' => 'info@jhigucms.com'],
|
|
['setting_name' => 'general_setting', 'name' => 'support_email_address', 'detail' => 'support@jhigucms.com'],
|
|
['setting_name' => 'general_setting', 'name' => 'opening_hours', 'detail' => '6:00 AM - 10:00 PM'],
|
|
['setting_name' => 'general_setting', 'name' => 'short_detail', 'detail' => "At Arogin Company, we're dedicated to simplifying your online journey. Our user-friendly Content Management System (CMS) empowers you to create, customize, and manage stunning websites effortlessly. With responsive design, scalability, and top-notch security, we're here to help you succeed in the digital world."],
|
|
['setting_name' => 'setting_image', 'name' => 'primary_image', 'detail' => 'jhigutechwhite.png'],
|
|
['setting_name' => 'setting_image', 'name' => 'secondary_image', 'detail' => 'jhigutechBlack.png'],
|
|
|
|
//-- Social media share
|
|
['setting_name' => 'social_setting', 'name' => 'facebook', 'detail' => 'http://facebook.com'],
|
|
['setting_name' => 'social_setting', 'name' => 'instagram', 'detail' => 'http://twitter.com'],
|
|
['setting_name' => 'social_setting', 'name' => 'twitter', 'detail' => 'http://instagram.com'],
|
|
['setting_name' => 'social_setting', 'name' => 'google', 'detail' => 'http://pinterest.com'],
|
|
|
|
//-- Seo Settings
|
|
['setting_name' => 'seo_setting', 'name' => 'meta_title', 'detail' => 'Arogin'],
|
|
['setting_name' => 'seo_setting', 'name' => 'meta_detail', 'detail' => 'This is SEO section of JhiguCMS from where you can improve your Search optimization over internet.'],
|
|
['setting_name' => 'seo_setting', 'name' => 'meta_keywords', 'detail' => 'JhiguCMS, CMS, Jhigu, Content Management System, Legit Developers, CMS Platform'],
|
|
|
|
//-- Additional setting
|
|
['setting_name' => 'additional_setting', 'name' => 'additional_script', 'detail' => 'A Content Management System (CMS) is software that simplifies creating, managing, and modifying digital content without advanced technical skills. Key features include content creation, organization, user management, version control, SEO optimization, themes/templates, plugins/extensions, security, performance optimization, and analytics/reporting. Popular CMS options include WordPress, Joomla, Drupal, Magento, Wix, Squarespace, Ghost, and Umbraco. When choosing a CMS, consider scalability, ease of use, flexibility, and suitability for your specific website needs.'],
|
|
['setting_name' => 'additional_setting', 'name' => 'map', 'detail' => '<iframe width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?width=100%25&height=400&hl=en&q=Bhaktapur%20Durbar%20Square+(Bhaktapur%20Durbar%20Square)&t=p&z=18&ie=UTF8&iwloc=B&output=embed"><a href="https://www.maps.ie/population/">Calculate population in area</a></iframe>'],
|
|
|
|
];
|
|
|
|
foreach ($settings as $setting) {
|
|
Setting::create([
|
|
'uuid' => Str::uuid(),
|
|
'setting_name' => $setting['setting_name'],
|
|
'name' => $setting['name'],
|
|
'detail' => $setting['detail'],
|
|
]);
|
|
}
|
|
|
|
$setting_images = Setting::where('setting_name', 'setting_image')->orderBy('id', 'ASC')->get();
|
|
foreach ($setting_images as $setting_image) {
|
|
$this->uploadImageForSetting($setting_image->detail, $setting_image, $setting_image->name);
|
|
}
|
|
}
|
|
|
|
private function uploadImageForSetting(string $imageFileName, $setting, $settingImageFieldName)
|
|
{
|
|
$seederDirPath = 'settings/';
|
|
|
|
// Generate a unique filename for the new image
|
|
$newFileName = Str::uuid() . '.jpg';
|
|
|
|
// Storage path for the new image
|
|
$storagePath = 'settings/' . $newFileName;
|
|
|
|
// Check if the image exists in the seeder_disk
|
|
if (Storage::disk('seeder_disk')->exists($seederDirPath . $imageFileName)) {
|
|
// Copy the image from seeder to public
|
|
$fileContents = Storage::disk('seeder_disk')->get($seederDirPath . $imageFileName);
|
|
|
|
Storage::disk('public_uploads')->put($storagePath, $fileContents);
|
|
|
|
$setting->name = $settingImageFieldName;
|
|
$setting->detail = $storagePath;
|
|
$setting->save();
|
|
}
|
|
}
|
|
}
|