2.1-2.4: install spatie/laravel-translatable, migrate to JSON, update models & controllers
Deploy Backend / deploy (push) Failing after 1m52s

This commit is contained in:
parsa aghaei committed 2026-06-23 18:31:51 +03:30
1 parent 75af8220a7
commit 37dd2c9d54
17 files changed
+453 -285

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
use HasFactory;
protected $fillable = [
'name',
'slug',
+3 -37
View File
@@ -4,50 +4,16 @@ namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
class AboutMe extends Model
{
use HasFactory;
use HasFactory, HasTranslations;
protected $table = 'website_about_me';
protected $fillable = ['image'];
/**
* ارتباط با ترجمه‌ها
*/
public function translations()
{
return $this->hasMany(AboutMeTranslation::class, 'about_me_id');
}
/**
* گرفتن ترجمه بر اساس زبان فعلی
*/
public function getTranslation($locale)
{
if ($this->relationLoaded('translations')) {
return $this->translations->firstWhere('locale', $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;
}
protected array $translatable = ['title', 'description'];
public function skills()
{
-22
View File
@@ -1,22 +0,0 @@
<?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');
}
}
+4 -6
View File
@@ -4,18 +4,16 @@ namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
class Project extends Model
{
use HasFactory;
use HasFactory, HasTranslations;
protected $table = 'website_projects'; // نام صحیح جدول
protected $table = 'website_projects';
protected $fillable = ['category_id', 'image1', 'image2'];
public function translations()
{
return $this->hasMany(ProjectTranslation::class, 'project_id');
}
protected array $translatable = ['title', 'description'];
public function category()
{
+4 -6
View File
@@ -4,16 +4,14 @@ namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
class ProjectCategory extends Model
{
use HasFactory;
use HasFactory, HasTranslations;
protected $table = 'website_project_categories'; // نام صحیح جدول
protected $table = 'website_project_categories';
protected $fillable = ['image'];
public function translations()
{
return $this->hasMany(ProjectCategoryTranslation::class, 'category_id');
}
protected array $translatable = ['title', 'description'];
}
@@ -1,14 +0,0 @@
<?php
namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProjectCategoryTranslation extends Model
{
use HasFactory;
protected $table = 'website_project_category_translations'; // نام صحیح جدول
protected $fillable = ['category_id', 'locale', 'title', 'description'];
}
-19
View File
@@ -1,19 +0,0 @@
<?php
namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProjectTranslation extends Model
{
use HasFactory;
protected $table = 'website_project_translations'; // نام صحیح جدول
protected $fillable = ['project_id', 'locale', 'title', 'description'];
public function project()
{
return $this->belongsTo(Project::class, 'project_id');
}
}
+5 -39
View File
@@ -4,48 +4,14 @@ namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
class Service extends Model
{
use HasFactory;
use HasFactory, HasTranslations;
protected $table = 'website_services'; // نام جدول
protected $fillable = ['imageSrc']; // فیلدهایی که قابل پر کردن هستند
protected $table = 'website_services';
protected $fillable = ['imageSrc'];
/**
* ارتباط با جدول ترجمه‌ها
*/
public function translations()
{
return $this->hasMany(ServiceTranslation::class, 'service_id');
}
/**
* گرفتن ترجمه بر اساس زبان فعلی
*/
public function getTranslation($locale)
{
if ($this->relationLoaded('translations')) {
return $this->translations->firstWhere('locale', $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;
}
protected array $translatable = ['title', 'description'];
}
-22
View File
@@ -1,22 +0,0 @@
<?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');
}
}
+6 -43
View File
@@ -4,56 +4,19 @@ namespace App\Models\Website;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
class Skill extends Model
{
use HasFactory;
use HasFactory, HasTranslations;
protected $table = 'website_skills'; // نام جدول
protected $fillable = ['image', 'link', 'about_me_id', 'percentage']; // فیلدهایی که قابل پر کردن هستند
protected $table = 'website_skills';
protected $fillable = ['image', 'link', 'about_me_id', 'percentage'];
protected array $translatable = ['title', 'description'];
/**
* ارتباط با جدول 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)
{
if ($this->relationLoaded('translations')) {
return $this->translations->firstWhere('locale', $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
View File
@@ -1,22 +0,0 @@
<?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');
}
}