Laravel Multi language site database

Laravel e-commerce site.

Arabic and English languages website. I have tried to develop Multilanguage site with laraval. But I am confused at the below point.

Suppose I have Category table with title field. I want to insert title field in the two language. So i have created migration for title_en and title_ar.

<?php
namespace App;
use App\Traits\MultiLanguage;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
use MultiLanguage;
protected $fillable = [
'title_en', 'title_ar',
];
/**
* This array will have the attributes which you want it to support multi languages
*/
protected $multi_lang = [
'title',
];
}

Here is multi language traits:

<?php

namespace App\Traits;
use Illuminate\Support\Facades\App;
trait MultiLanguage
{

public function __get($key)
{
if (isset($this->multi_lang) && in_array($key, $this->multi_lang)) {
$key = $key . '_' . App::getLocale();
}
return parent::__get($key);
}
}

But what to do when there are many table fields also how to insert records. If You have any solution. Please guide me. how can it possible?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32NdO8m
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time