internationalization added and backend updated until services
This commit is contained in:
parent
9bcf1fb0eb
commit
027d1090df
82
app/Http/Controllers/Website/AboutMeController.php
Normal file
82
app/Http/Controllers/Website/AboutMeController.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Website\AboutMe;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class AboutMeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$aboutMe = AboutMe::with('skills.translations')->first(); // بارگذاری مهارتها و ترجمهها
|
||||
return response()->json($aboutMe);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$aboutMe = AboutMe::with('skills.translations')->findOrFail($id);
|
||||
return response()->json($aboutMe);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$aboutMe = AboutMe::create($request->all());
|
||||
return response()->json($aboutMe, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$aboutMe = AboutMe::findOrFail($id);
|
||||
$aboutMe->update($request->all());
|
||||
return response()->json($aboutMe);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
AboutMe::destroy($id);
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
// متد جدید برای دریافت ترجمه بر اساس locale از کوکی
|
||||
public function getTranslation($id, $locale)
|
||||
{
|
||||
// بارگذاری AboutMe با ترجمههای مربوط به locale و مهارتها
|
||||
$aboutMe = AboutMe::with(['translations' => function ($query) use ($locale) {
|
||||
$query->where('locale', $locale);
|
||||
}, 'skills.translations' => function ($query) use ($locale) {
|
||||
$query->where('locale', $locale);
|
||||
}])->findOrFail($id);
|
||||
|
||||
// اگر ترجمه موجود نیست، میتوانید ترجمه پیشفرض یا خطا را برگردانید
|
||||
if ($aboutMe->translations->isEmpty()) {
|
||||
return response()->json(['message' => 'Translation not found', 'locale' => $locale], 404);
|
||||
}
|
||||
|
||||
// ترکیب اطلاعات AboutMe و ترجمه
|
||||
$translation = $aboutMe->translations->first(); // فقط یک ترجمه دریافت میکنیم
|
||||
$skills = $aboutMe->skills->map(function ($skill) use ($locale) {
|
||||
$translation = $skill->getTranslation($locale); // گرفتن ترجمه برای هر مهارت
|
||||
|
||||
return [
|
||||
'id' => $skill->id,
|
||||
'title' => $translation ? $translation->title : null, // عنوان از ترجمه
|
||||
'description' => $translation ? $translation->description : null, // توضیحات از ترجمه
|
||||
'image' => $skill->image, // تصویر
|
||||
'link' => $skill->link, // لینک
|
||||
'percentage' => $skill->percentage, // درصد
|
||||
];
|
||||
});
|
||||
|
||||
$data = [
|
||||
'id' => $aboutMe->id,
|
||||
'title' => $translation->title,
|
||||
'description' => $translation->description,
|
||||
'image' => $aboutMe->image,
|
||||
'skills' => $skills, // مهارتها اکنون بارگذاری شدهاند
|
||||
];
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
50
app/Http/Controllers/Website/ServiceController.php
Normal file
50
app/Http/Controllers/Website/ServiceController.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Website\Service;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* دریافت لیست خدمات با ترجمهها بر اساس زبان
|
||||
*/
|
||||
public function index($locale)
|
||||
{
|
||||
// گرفتن همه خدمات به همراه ترجمهها
|
||||
$services = Service::with(['translations' => function ($query) use ($locale) {
|
||||
$query->where('locale', $locale);
|
||||
}])->get();
|
||||
|
||||
// فرمتی که میخواهیم به کاربر ارسال کنیم
|
||||
$response = $services->map(function ($service) use ($locale) {
|
||||
return [
|
||||
'id' => $service->id,
|
||||
'imageSrc' => $service->imageSrc,
|
||||
'altText' => $service->translations->first()->altText ?? '',
|
||||
'created_at' => $service->created_at,
|
||||
'updated_at' => $service->updated_at,
|
||||
'title' => optional($service->translations->first())->title,
|
||||
'description' => optional($service->translations->first())->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* نمایش یک خدمت خاص با ترجمه
|
||||
*/
|
||||
public function showTranslation($id, $locale)
|
||||
{
|
||||
$service = Service::with('translations')->findOrFail($id);
|
||||
|
||||
return response()->json([
|
||||
'id' => $service->id,
|
||||
'imageSrc' => $service->imageSrc,
|
||||
'title' => $service->getTitle($locale),
|
||||
'description' => $service->getDescription($locale),
|
||||
]);
|
||||
}
|
||||
}
|
||||
53
app/Models/Website/AboutMe.php
Normal file
53
app/Models/Website/AboutMe.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Website;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AboutMe extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'website_about_me';
|
||||
protected $fillable = ['image'];
|
||||
|
||||
/**
|
||||
* ارتباط با ترجمهها
|
||||
*/
|
||||
public function translations()
|
||||
{
|
||||
return $this->hasMany(AboutMeTranslation::class, 'about_me_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن ترجمه بر اساس زبان فعلی
|
||||
*/
|
||||
public function getTranslation($locale)
|
||||
{
|
||||
return $this->translations()->where('locale', $locale)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن عنوان بر اساس زبان فعلی
|
||||
*/
|
||||
public function getTitle($locale)
|
||||
{
|
||||
$translation = $this->getTranslation($locale);
|
||||
return $translation ? $translation->title : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن توضیحات بر اساس زبان فعلی
|
||||
*/
|
||||
public function getDescription($locale)
|
||||
{
|
||||
$translation = $this->getTranslation($locale);
|
||||
return $translation ? $translation->description : null;
|
||||
}
|
||||
|
||||
public function skills()
|
||||
{
|
||||
return $this->hasMany(Skill::class);
|
||||
}
|
||||
}
|
||||
22
app/Models/Website/AboutMeTranslation.php
Normal file
22
app/Models/Website/AboutMeTranslation.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Website;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AboutMeTranslation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'website_about_me_translations';
|
||||
protected $fillable = ['about_me_id', 'locale', 'title', 'description'];
|
||||
|
||||
/**
|
||||
* ارتباط با AboutMe
|
||||
*/
|
||||
public function aboutMe()
|
||||
{
|
||||
return $this->belongsTo(AboutMe::class, 'about_me_id');
|
||||
}
|
||||
}
|
||||
48
app/Models/Website/Service.php
Normal file
48
app/Models/Website/Service.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Website;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'website_services'; // نام جدول
|
||||
protected $fillable = ['imageSrc']; // فیلدهایی که قابل پر کردن هستند
|
||||
|
||||
/**
|
||||
* ارتباط با جدول ترجمهها
|
||||
*/
|
||||
public function translations()
|
||||
{
|
||||
return $this->hasMany(ServiceTranslation::class, 'service_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن ترجمه بر اساس زبان فعلی
|
||||
*/
|
||||
public function getTranslation($locale)
|
||||
{
|
||||
return $this->translations()->where('locale', $locale)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن عنوان بر اساس زبان فعلی
|
||||
*/
|
||||
public function getTitle($locale)
|
||||
{
|
||||
$translation = $this->getTranslation($locale);
|
||||
return $translation ? $translation->title : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن توضیحات بر اساس زبان فعلی
|
||||
*/
|
||||
public function getDescription($locale)
|
||||
{
|
||||
$translation = $this->getTranslation($locale);
|
||||
return $translation ? $translation->description : null;
|
||||
}
|
||||
}
|
||||
22
app/Models/Website/ServiceTranslation.php
Normal file
22
app/Models/Website/ServiceTranslation.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Website;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceTranslation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'website_service_translations'; // نام جدول
|
||||
protected $fillable = ['service_id', 'locale', 'title', 'description']; // فیلدهایی که قابل پر کردن هستند
|
||||
|
||||
/**
|
||||
* ارتباط با جدول خدمات
|
||||
*/
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class, 'service_id');
|
||||
}
|
||||
}
|
||||
56
app/Models/Website/Skill.php
Normal file
56
app/Models/Website/Skill.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Website;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Skill extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'website_skills'; // نام جدول
|
||||
protected $fillable = ['image', 'link', 'about_me_id', 'percentage']; // فیلدهایی که قابل پر کردن هستند
|
||||
|
||||
/**
|
||||
* ارتباط با جدول AboutMe
|
||||
*/
|
||||
public function aboutMe()
|
||||
{
|
||||
return $this->belongsTo(AboutMe::class, 'about_me_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* ارتباط با جدول ترجمهها
|
||||
*/
|
||||
public function translations()
|
||||
{
|
||||
return $this->hasMany(SkillTranslation::class, 'skill_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن ترجمه بر اساس زبان فعلی
|
||||
*/
|
||||
public function getTranslation($locale)
|
||||
{
|
||||
return $this->translations()->where('locale', $locale)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن عنوان بر اساس زبان فعلی
|
||||
*/
|
||||
public function getTitle($locale)
|
||||
{
|
||||
$translation = $this->getTranslation($locale);
|
||||
return $translation ? $translation->title : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* گرفتن توضیحات بر اساس زبان فعلی
|
||||
*/
|
||||
public function getDescription($locale)
|
||||
{
|
||||
$translation = $this->getTranslation($locale);
|
||||
return $translation ? $translation->description : null;
|
||||
}
|
||||
}
|
||||
22
app/Models/Website/SkillTranslation.php
Normal file
22
app/Models/Website/SkillTranslation.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Website;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SkillTranslation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'website_skill_translations'; // نام جدول
|
||||
protected $fillable = ['skill_id', 'locale', 'title', 'description']; // فیلدهایی که قابل پر کردن هستند
|
||||
|
||||
/**
|
||||
* ارتباط با جدول Skills
|
||||
*/
|
||||
public function skill()
|
||||
{
|
||||
return $this->belongsTo(Skill::class, 'skill_id');
|
||||
}
|
||||
}
|
||||
34
config/cors.php
Normal file
34
config/cors.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your settings for cross-origin resource sharing
|
||||
| or "CORS". This determines what cross-origin operations may execute
|
||||
| in web browsers. You are free to adjust these settings as needed.
|
||||
|
|
||||
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => true,
|
||||
|
||||
];
|
||||
@ -1,30 +0,0 @@
|
||||
<?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('about_me', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->text('description');
|
||||
$table->string('image'); // URL تصویر
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('about_me');
|
||||
}
|
||||
};
|
||||
@ -1,32 +0,0 @@
|
||||
<?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('skills', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('image'); // URL تصویر
|
||||
$table->text('description'); // توضیحات
|
||||
$table->string('link'); // لینک
|
||||
$table->foreignId('about_me_id')->constrained('about_me')->onDelete('cascade'); // ارتباط با جدول about_me
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('skills');
|
||||
}
|
||||
};
|
||||
@ -1,28 +0,0 @@
|
||||
<?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()
|
||||
{
|
||||
Schema::table('skills', function (Blueprint $table) {
|
||||
$table->integer('percentage')->after('description'); // اضافه کردن ستون درصد
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('skills', function (Blueprint $table) {
|
||||
$table->dropColumn('percentage');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,48 @@
|
||||
<?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
|
||||
{
|
||||
// جدول اصلی about_me
|
||||
Schema::create('website_about_me', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image'); // URL تصویر
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// جدول ترجمه برای about_me
|
||||
Schema::create('website_about_me_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('about_me_id');
|
||||
$table->string('locale')->index(); // زبان (fa, en و غیره)
|
||||
$table->string('title');
|
||||
$table->text('description');
|
||||
$table->timestamps();
|
||||
|
||||
// ارتباط با جدول اصلی
|
||||
$table->foreign('about_me_id')->references('id')->on('website_about_me')->onDelete('cascade');
|
||||
|
||||
// جلوگیری از تکرار یک زبان برای هر about_me
|
||||
$table->unique(['about_me_id', 'locale']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// ابتدا جدول ترجمه باید حذف شود
|
||||
Schema::dropIfExists('website_about_me_translations');
|
||||
// سپس جدول اصلی حذف میشود
|
||||
Schema::dropIfExists('website_about_me');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,46 @@
|
||||
<?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
|
||||
{
|
||||
// جدول اصلی skills
|
||||
Schema::create('website_skills', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image'); // URL تصویر
|
||||
$table->string('link')->nullable(); // لینک
|
||||
$table->foreignId('about_me_id')->constrained('website_about_me')->onDelete('cascade'); // ارتباط با جدول website_about_me
|
||||
$table->integer('percentage'); // درصد
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// جدول ترجمه برای skills
|
||||
Schema::create('website_skill_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('skill_id')->constrained('website_skills')->onDelete('cascade'); // ارتباط با جدول website_skills
|
||||
$table->string('locale')->index(); // مشخص کردن زبان
|
||||
$table->string('title'); // عنوان ترجمهشده
|
||||
$table->text('description'); // توضیحات ترجمهشده
|
||||
$table->unique(['skill_id', 'locale']); // جلوگیری از تکرار ترجمه برای هر زبان
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// ابتدا جدول ترجمه باید حذف شود
|
||||
Schema::dropIfExists('website_skill_translations');
|
||||
// سپس جدول اصلی حذف میشود
|
||||
Schema::dropIfExists('website_skills');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,48 @@
|
||||
<?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
|
||||
{
|
||||
// جدول اصلی services
|
||||
Schema::create('website_services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('imageSrc'); // URL تصویر
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// جدول ترجمه برای services
|
||||
Schema::create('website_service_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('service_id'); // کلید خارجی به جدول اصلی
|
||||
$table->string('locale')->index(); // زبان (fa, en و غیره)
|
||||
$table->string('title'); // عنوان ترجمهشده
|
||||
$table->text('description'); // توضیحات ترجمهشده
|
||||
$table->timestamps();
|
||||
|
||||
// ارتباط با جدول اصلی
|
||||
$table->foreign('service_id')->references('id')->on('website_services')->onDelete('cascade');
|
||||
|
||||
// جلوگیری از تکرار یک زبان برای هر سرویس
|
||||
$table->unique(['service_id', 'locale']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// ابتدا جدول ترجمه باید حذف شود
|
||||
Schema::dropIfExists('website_service_translations');
|
||||
// سپس جدول اصلی حذف میشود
|
||||
Schema::dropIfExists('website_services');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,50 @@
|
||||
<?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
|
||||
{
|
||||
// جدول اصلی testimonials
|
||||
Schema::create('website_testimonials', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image'); // URL تصویر
|
||||
$table->string('client_link'); // لینک از طرف
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// جدول ترجمه برای testimonials
|
||||
Schema::create('website_testimonial_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('testimonial_id'); // کلید خارجی به جدول اصلی
|
||||
$table->string('locale')->index(); // زبان (fa, en و غیره)
|
||||
$table->string('client_name'); // نام ترجمهشده
|
||||
$table->string('client_position'); // سمت ترجمهشده
|
||||
$table->text('feedback'); // نظر ترجمهشده
|
||||
$table->timestamps();
|
||||
|
||||
// ارتباط با جدول اصلی
|
||||
$table->foreign('testimonial_id')->references('id')->on('website_testimonials')->onDelete('cascade');
|
||||
|
||||
// جلوگیری از تکرار یک زبان برای هر testimonial
|
||||
$table->unique(['testimonial_id', 'locale']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// ابتدا جدول ترجمه باید حذف شود
|
||||
Schema::dropIfExists('website_testimonial_translations');
|
||||
// سپس جدول اصلی حذف میشود
|
||||
Schema::dropIfExists('website_testimonials');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,48 @@
|
||||
<?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
|
||||
{
|
||||
// جدول اصلی website_project_categories
|
||||
Schema::create('website_project_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image'); // URL تصویر
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// جدول ترجمه برای website_project_categories
|
||||
Schema::create('website_project_category_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('category_id'); // کلید خارجی به جدول اصلی
|
||||
$table->string('locale')->index(); // زبان (fa, en و غیره)
|
||||
$table->string('title'); // عنوان ترجمهشده
|
||||
$table->text('description'); // توضیحات ترجمهشده
|
||||
$table->timestamps();
|
||||
|
||||
// ارتباط با جدول اصلی
|
||||
$table->foreign('category_id')->references('id')->on('website_project_categories')->onDelete('cascade');
|
||||
|
||||
// جلوگیری از تکرار یک زبان برای هر دستهبندی
|
||||
$table->unique(['category_id', 'locale']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// ابتدا جدول ترجمه باید حذف شود
|
||||
Schema::dropIfExists('website_project_category_translations');
|
||||
// سپس جدول اصلی حذف میشود
|
||||
Schema::dropIfExists('website_project_categories');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,50 @@
|
||||
<?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
|
||||
{
|
||||
// جدول اصلی website_projects
|
||||
Schema::create('website_projects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->constrained('website_project_categories')->onDelete('cascade'); // کلید خارجی به جدول categories
|
||||
$table->string('image1'); // عنوان ترجمهشده
|
||||
$table->string('image2'); // عنوان ترجمهشده
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// جدول ترجمه برای website_projects
|
||||
Schema::create('website_project_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('project_id'); // کلید خارجی به جدول اصلی
|
||||
$table->string('locale')->index(); // زبان (fa, en و غیره)
|
||||
$table->string('title'); // عنوان ترجمهشده
|
||||
$table->text('description'); // توضیحات ترجمهشده
|
||||
$table->timestamps();
|
||||
|
||||
// ارتباط با جدول اصلی
|
||||
$table->foreign('project_id')->references('id')->on('website_projects')->onDelete('cascade');
|
||||
|
||||
// جلوگیری از تکرار یک زبان برای هر پروژه
|
||||
$table->unique(['project_id', 'locale']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// ابتدا جدول ترجمه باید حذف شود
|
||||
Schema::dropIfExists('website_project_translations');
|
||||
// سپس جدول اصلی حذف میشود
|
||||
Schema::dropIfExists('website_projects');
|
||||
}
|
||||
};
|
||||
@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\AboutMe;
|
||||
use App\Models\Skill;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AboutMeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// ایجاد رکورد AboutMe
|
||||
$aboutMe = AboutMe::create([
|
||||
'title' => 'About Me',
|
||||
'description' => 'I am a web developer with over 10 years of experience in creating dynamic and user-centric web applications. Specializing in React and Next.js, I build scalable solutions that enhance performance and user experience. I enjoy tackling complex challenges, from improving legacy systems to developing new applications. My focus on frontend development and seamless backend integration allows me to deliver innovative results while staying current with industry trends.',
|
||||
'image' => '/images/profile.png',
|
||||
]);
|
||||
|
||||
// ایجاد رکوردهای Skill
|
||||
Skill::create([
|
||||
'title' => 'HTML & CSS (SASS, Responsive Design)',
|
||||
'image' => '/images/frontend.png',
|
||||
'description' => 'HTML & CSS (SASS, Responsive Design) description',
|
||||
'link' => 'http://example.com/frontend',
|
||||
'percentage' => 95,
|
||||
'about_me_id' => $aboutMe->id,
|
||||
]);
|
||||
|
||||
Skill::create([
|
||||
'title' => 'React.js and Next.js Development',
|
||||
'image' => '/images/backend.png',
|
||||
'description' => 'React.js and Next.js Development description.',
|
||||
'link' => 'http://example.com/backend',
|
||||
'percentage' => 90,
|
||||
'about_me_id' => $aboutMe->id,
|
||||
]);
|
||||
Skill::create([
|
||||
'title' => 'Backend Development (RESTful APIs, Laravel)',
|
||||
'image' => '/images/ui.png',
|
||||
'description' => 'Backend Development (RESTful APIs, Laravel) description.',
|
||||
'link' => 'http://example.com/ui',
|
||||
'percentage' => 85,
|
||||
'about_me_id' => $aboutMe->id,
|
||||
]);
|
||||
|
||||
Skill::create([
|
||||
'title' => 'WordPress Development and Customization',
|
||||
'image' => '/images/ux.png',
|
||||
'description' => 'WordPress Development and Customization description.',
|
||||
'link' => 'http://example.com/ux',
|
||||
'percentage' => 90,
|
||||
'about_me_id' => $aboutMe->id,
|
||||
]);
|
||||
|
||||
Skill::create([
|
||||
'title' => 'Version Control (Git, GitHub)',
|
||||
'image' => '/images/ux.png',
|
||||
'description' => 'Version Control (Git, GitHub) description.',
|
||||
'link' => 'http://example.com/ux',
|
||||
'percentage' => 80,
|
||||
'about_me_id' => $aboutMe->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Database\Seeders\Blog\BlogSeeder;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Database\Seeders\Website\AboutMeSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
||||
151
database/seeders/Website/AboutMeSeeder.php
Normal file
151
database/seeders/Website/AboutMeSeeder.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Website;
|
||||
|
||||
use App\Models\Website\AboutMe;
|
||||
use App\Models\Website\AboutMeTranslation;
|
||||
use App\Models\Website\Skill;
|
||||
use App\Models\Website\SkillTranslation;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AboutMeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// ایجاد رکورد AboutMe بدون ترجمه
|
||||
$aboutMe = AboutMe::create([
|
||||
'image' => '/images/profile.png',
|
||||
]);
|
||||
|
||||
// ایجاد ترجمه انگلیسی
|
||||
AboutMeTranslation::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'locale' => 'en',
|
||||
'title' => 'About Me',
|
||||
'description' => 'I am a web developer with over 10 years of experience in creating dynamic and user-centric web applications. Specializing in React and Next.js, I build scalable solutions that enhance performance and user experience. I enjoy tackling complex challenges, from improving legacy systems to developing new applications. My focus on frontend development and seamless backend integration allows me to deliver innovative results while staying current with industry trends.',
|
||||
]);
|
||||
|
||||
// ایجاد ترجمه فارسی
|
||||
AboutMeTranslation::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'locale' => 'fa',
|
||||
'title' => 'درباره من',
|
||||
'description' => 'من یک توسعهدهنده وب با بیش از 10 سال تجربه در ایجاد برنامههای وب پویا و کاربرمحور هستم. با تخصص در React و Next.js، راهحلهای مقیاسپذیری ایجاد میکنم که عملکرد و تجربه کاربری را بهبود میبخشند. من از حل چالشهای پیچیده لذت میبرم، از بهبود سیستمهای قدیمی گرفته تا توسعه برنامههای جدید. تمرکز من بر توسعه فرانتاند و یکپارچهسازی بیدردسر با بکاند به من این امکان را میدهد که نتایج نوآورانهای ارائه دهم و همزمان با روندهای صنعت بهروز باشم.',
|
||||
]);
|
||||
|
||||
// ایجاد رکوردهای Skill و ترجمههای انگلیسی و فارسی
|
||||
|
||||
// HTML & CSS (SASS, Responsive Design)
|
||||
$htmlSkill = Skill::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'image' => '/images/frontend.png',
|
||||
'percentage' => 95,
|
||||
'link' => 'http://example.com/frontend',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $htmlSkill->id,
|
||||
'locale' => 'en',
|
||||
'title' => 'HTML & CSS (SASS, Responsive Design)',
|
||||
'description' => 'Skilled in HTML5, CSS3, including SASS for modular and maintainable stylesheets. Experienced in building responsive web designs.',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $htmlSkill->id,
|
||||
'locale' => 'fa',
|
||||
'title' => 'HTML و CSS (SASS، طراحی واکنشگرا)',
|
||||
'description' => 'مهارت در HTML5، CSS3، شامل SASS برای ساخت استایلهای مدولار و قابل نگهداری. تجربه در طراحی وبسایتهای واکنشگرا.',
|
||||
]);
|
||||
|
||||
// React.js and Next.js Development
|
||||
$reactSkill = Skill::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'image' => '/images/backend.png',
|
||||
'percentage' => 90,
|
||||
'link' => 'http://example.com/backend',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $reactSkill->id,
|
||||
'locale' => 'en',
|
||||
'title' => 'React.js and Next.js Development',
|
||||
'description' => 'Extensive experience in React.js and Next.js for building scalable and performant web applications.',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $reactSkill->id,
|
||||
'locale' => 'fa',
|
||||
'title' => 'توسعه React.js و Next.js',
|
||||
'description' => 'تجربه گسترده در توسعه React.js و Next.js برای ساخت برنامههای وب مقیاسپذیر و پرکاربرد.',
|
||||
]);
|
||||
|
||||
// Backend Development (RESTful APIs, Laravel)
|
||||
$backendSkill = Skill::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'image' => '/images/ui.png',
|
||||
'percentage' => 85,
|
||||
'link' => 'http://example.com/ui',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $backendSkill->id,
|
||||
'locale' => 'en',
|
||||
'title' => 'Backend Development (RESTful APIs, Laravel)',
|
||||
'description' => 'Proficient in backend development, building robust RESTful APIs using Laravel and other technologies.',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $backendSkill->id,
|
||||
'locale' => 'fa',
|
||||
'title' => 'توسعه بکاند (APIهای RESTful، لاراول)',
|
||||
'description' => 'تسلط به توسعه بکاند و ساخت APIهای RESTful با استفاده از لاراول و دیگر تکنولوژیها.',
|
||||
]);
|
||||
|
||||
// WordPress Development and Customization
|
||||
$wordpressSkill = Skill::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'image' => '/images/ux.png',
|
||||
'percentage' => 90,
|
||||
'link' => 'http://example.com/ux',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $wordpressSkill->id,
|
||||
'locale' => 'en',
|
||||
'title' => 'WordPress Development and Customization',
|
||||
'description' => 'Skilled in WordPress development, including theme customization and plugin development.',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $wordpressSkill->id,
|
||||
'locale' => 'fa',
|
||||
'title' => 'توسعه و شخصیسازی وردپرس',
|
||||
'description' => 'مهارت در توسعه وردپرس، شامل شخصیسازی قالبها و توسعه افزونهها.',
|
||||
]);
|
||||
|
||||
// Version Control (Git, GitHub)
|
||||
$gitSkill = Skill::create([
|
||||
'about_me_id' => $aboutMe->id,
|
||||
'image' => '/images/ux.png',
|
||||
'percentage' => 80,
|
||||
'link' => 'http://example.com/ux',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $gitSkill->id,
|
||||
'locale' => 'en',
|
||||
'title' => 'Version Control (Git, GitHub)',
|
||||
'description' => 'Experienced in version control using Git and GitHub for managing codebases and collaboration.',
|
||||
]);
|
||||
|
||||
SkillTranslation::create([
|
||||
'skill_id' => $gitSkill->id,
|
||||
'locale' => 'fa',
|
||||
'title' => 'کنترل نسخه (Git, GitHub)',
|
||||
'description' => 'تجربه در کنترل نسخه با استفاده از Git و GitHub برای مدیریت کدها و همکاری تیمی.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
96
database/seeders/Website/ServiceSeeder.php
Normal file
96
database/seeders/Website/ServiceSeeder.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\website;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Website\Service;
|
||||
use App\Models\Website\ServiceTranslation;
|
||||
|
||||
class ServiceSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// خدمات با ترجمههای فارسی
|
||||
$services = [
|
||||
[
|
||||
'imageSrc' => '/images/ui-ux-vector.svg',
|
||||
'translations' => [
|
||||
[
|
||||
'locale' => 'fa',
|
||||
'title' => 'توسعه وب سفارشی',
|
||||
'description' => 'ما برنامههای وب سفارشی را ایجاد میکنیم که نیازهای خاص کسبوکار شما را برآورده میسازد و از آخرین تکنولوژیها برای عملکرد بهینه استفاده میکند.',
|
||||
],
|
||||
[
|
||||
'locale' => 'en',
|
||||
'title' => 'Custom Web Development',
|
||||
'description' => 'We create tailored web applications that meet your unique business requirements, utilizing the latest technologies for optimal performance.',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'imageSrc' => '/images/web-design-vector.svg',
|
||||
'translations' => [
|
||||
[
|
||||
'locale' => 'fa',
|
||||
'title' => 'توسعه فرانتاند',
|
||||
'description' => 'خدمات توسعه فرانتاند ما بر روی ایجاد رابطهای کاربری جذاب و پاسخگو تمرکز دارد که تجربه کاربری را در تمامی دستگاهها بهبود میبخشد.',
|
||||
],
|
||||
[
|
||||
'locale' => 'en',
|
||||
'title' => 'Frontend Development',
|
||||
'description' => 'Our frontend development services focus on crafting engaging, responsive user interfaces that enhance user experience across all devices.',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'imageSrc' => '/images/app-design-vector.svg',
|
||||
'translations' => [
|
||||
[
|
||||
'locale' => 'fa',
|
||||
'title' => 'توسعه بکاند',
|
||||
'description' => 'ما راهحلهای قابل اعتماد توسعه بکاند را ارائه میدهیم و معماریهای سروری و APIهای قوی را برای اطمینان از عملکرد روان و ایمن برنامه ایجاد میکنیم.',
|
||||
],
|
||||
[
|
||||
'locale' => 'en',
|
||||
'title' => 'Backend Development',
|
||||
'description' => 'We provide reliable backend development solutions, building robust server-side architectures and APIs to ensure smooth and secure application functionality.',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'imageSrc' => '/images/graphic-design-vector.svg',
|
||||
'translations' => [
|
||||
[
|
||||
'locale' => 'fa',
|
||||
'title' => 'نگهداری و پشتیبانی وبسایت',
|
||||
'description' => 'خدمات نگهداری و پشتیبانی مداوم ما وبسایت شما را بهروز، امن و با بهترین عملکرد نگه میدارد تا شما بتوانید بر روی کسبوکار اصلی خود تمرکز کنید.',
|
||||
],
|
||||
[
|
||||
'locale' => 'en',
|
||||
'title' => 'Website Maintenance and Support',
|
||||
'description' => 'Our ongoing maintenance and support services keep your website updated, secure, and performing at its best, allowing you to focus on your core business.',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// ذخیره خدمات و ترجمهها
|
||||
foreach ($services as $serviceData) {
|
||||
$service = Service::create([
|
||||
'imageSrc' => $serviceData['imageSrc'],
|
||||
]);
|
||||
|
||||
foreach ($serviceData['translations'] as $translation) {
|
||||
ServiceTranslation::create([
|
||||
'service_id' => $service->id,
|
||||
'locale' => $translation['locale'],
|
||||
'title' => $translation['title'],
|
||||
'description' => $translation['description'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,23 +3,27 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\ProjectController;
|
||||
use App\Http\Controllers\AboutMeController;
|
||||
use App\Http\Controllers\Blog\CategoryController;
|
||||
use App\Http\Controllers\Blog\HomeController;
|
||||
use App\Http\Controllers\Blog\PostController;
|
||||
use App\Http\Controllers\Blog\TagController;
|
||||
use App\Http\Controllers\SkillController;
|
||||
use App\Http\Controllers\ServiceController;
|
||||
use App\Http\Controllers\Website\ServiceController;
|
||||
use App\Http\Controllers\Website\AboutMeController;
|
||||
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
})->middleware('auth:sanctum');
|
||||
|
||||
|
||||
Route::resource('projects', ProjectController::class);
|
||||
Route::resource('about-me', AboutMeController::class);
|
||||
|
||||
Route::resource('skills', SkillController::class);
|
||||
Route::apiResource('services', ServiceController::class);
|
||||
Route::prefix('website')->group(function () {
|
||||
Route::get('about-me/{id}/translation/{locale}', [AboutMeController::class, 'getTranslation']);
|
||||
Route::get('services/{locale}', [ServiceController::class, 'index']); // مسیر جدید برای لیست خدمات با ترجمه
|
||||
Route::get('services/{id}/translation/{locale}', [ServiceController::class, 'showTranslation']);
|
||||
});
|
||||
|
||||
// مسیرهای بلاگ
|
||||
Route::prefix('blog')->group(function () {
|
||||
@ -32,5 +36,4 @@
|
||||
// مسیر Homepage
|
||||
Route::get('homepage', [HomeController::class, 'index']);
|
||||
Route::get('categories/{slug}/posts', [CategoryController::class, 'getCategoryWithPosts']);
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user