firstcommit
This commit is contained in:
0
Modules/Service/database/factories/.gitkeep
Normal file
0
Modules/Service/database/factories/.gitkeep
Normal file
0
Modules/Service/database/migrations/.gitkeep
Normal file
0
Modules/Service/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->string('title');
|
||||
$table->text('summary')->nullable();
|
||||
$table->longText('detail')->nullable();;
|
||||
$table->string('image')->nullable();
|
||||
$table->string('image_path')->nullable();
|
||||
$table->string('status')->default('active');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('services');
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('service_metas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->unsignedBigInteger('service_id');
|
||||
$table->string('meta_title')->nullable();
|
||||
$table->longText('meta_description')->nullable();
|
||||
$table->longText('meta_keywords')->nullable();
|
||||
$table->softDeletes();
|
||||
$table->foreign('service_id')->references('id')->on('services');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('service_metas');
|
||||
}
|
||||
};
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Schema::table('services', function (Blueprint $table) {
|
||||
// $table->boolean('homepage_flag')->default(false)->after('image_path');
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('services', function (Blueprint $table) {
|
||||
// $table->dropColumn('homepage_flag');
|
||||
// });
|
||||
}
|
||||
};
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->string('slug', 300)->after('title');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
}
|
||||
};
|
0
Modules/Service/database/seeders/.gitkeep
Normal file
0
Modules/Service/database/seeders/.gitkeep
Normal file
83
Modules/Service/database/seeders/ServiceDatabaseSeeder.php
Normal file
83
Modules/Service/database/seeders/ServiceDatabaseSeeder.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\database\seeders;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Service\app\Models\Service;
|
||||
|
||||
class ServiceDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
||||
$services = [
|
||||
[
|
||||
'title' => 'PSYCHIATRY',
|
||||
'slug' => 'psychiatry',
|
||||
'summary' => null,
|
||||
'detail' => 'Psychiatry is one of the neglected fields in our country where even today we are fighting to establish psychiatric illnesses as medical disorders in true sense. A mental illness is not a character flaw. It is caused by genetic, biological, social and environmental factors. According to a report from the World Health Organization (WHO) one in four people around the world suffer from mental health problems at some point in their lives. With appropriate treatment and support, people with mental illness can have normal life and live successfully in their community. It is high time we took these illnesses seriously.',
|
||||
'image' => 's1.png'
|
||||
],
|
||||
[
|
||||
'title' => 'GERIATRIC MEDICINE',
|
||||
'slug' => 'generic-medicine',
|
||||
'summary' => null,
|
||||
'detail' => 'Demographic transition has become the norm of the current world. The booming geriatric population has posed serious challenges to the socio-economic aspects of every nation round the globe. How could Nepal be an exception to this global trend? Nepal is a country where very few people are aware about Geriatric medicine. In our context, even the established giants of general medicine are ignorant about the essence of this discipline.
|
||||
|
||||
Geriatrics or geriatric medicine is a specialty that focuses on health care of elderly people. It aims to promote health by preventing and treating diseases and disabilities in older adults Geriatric medicine is in its inception in our country and we have the responsibility to nurture its infancy.',
|
||||
'image' => 's2.png'
|
||||
],
|
||||
[
|
||||
'title' => 'PEDIATRICS',
|
||||
'slug' => 'pediatrics',
|
||||
'summary' => null,
|
||||
'detail' => '“The child who has health has hope and the one who has hope has everything. Let’s nourish hope from your home.”
|
||||
|
||||
Child care and adolescent health are beautiful sweet challenges for any families. Every child/adolescent has the right to health, to education, to protection and to tenderness to life. Nation builds on parents hand via vulnerable soft marks of their kids’ footsteps. The most overwhelming key to a child`s successful future is the full positive involvement of the parents in holistic way. Quality health care, optimum education provision and child friendly environment make it possible for welfare recipient kids to secure better future. Sadly, Children of developing countries are far deprived from quality health care and good guidance. Basic needs like growth, development, nutrition immunization and many more aspects are yet to be fulfilled. We have a vision where all children and adolescents are healthy and live in dignity with choices and opportunities. When it comes for a child health there is no ‘them’, it’s only ‘us’. We have a promise for promising child care and guidance. Let`s proceed ahead for your child`s best health. Let`s build profound hope on your kids roadmap.',
|
||||
'image' => 's3.png'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
$cmsService = Service::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'title' => $service['title'],
|
||||
'summary' => $service['summary'],
|
||||
'detail' => $service['detail'],
|
||||
'slug' => $service['slug'],
|
||||
// 'homepage_flag' => $service['homepage_flag'],
|
||||
]);
|
||||
|
||||
// Add image to the created banner
|
||||
$this->uploadImageForService($service['image'], $cmsService);
|
||||
}
|
||||
}
|
||||
private function uploadImageForService(string $imageFileName, $cmsService)
|
||||
{
|
||||
$seederDirPath = 'services/';
|
||||
|
||||
// Generate a unique filename for the new image
|
||||
$newFileName = Str::uuid() . '.jpg';
|
||||
|
||||
// Storage path for the new image
|
||||
$storagePath = '/services/' . $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);
|
||||
|
||||
$cmsService->image = $newFileName;
|
||||
$cmsService->image_path = $storagePath;
|
||||
$cmsService->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user