承接 echosters/translatable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

echosters/translatable

最新稳定版本:v1.0.5

Composer 安装命令:

composer require echosters/translatable

包简介

Translatable is Laravel Package helps you dealing with multi-lang tables

README 文档

README

Translatable is a Laravel package for dealing with Multi-Lang Tables.

Installation

Using composer to install translatable.

composer require echosters/translatable

DataBase

id title_en title_ar
1 Hello مرحبا

Preparing your model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Echosters\Translatable\Translatable;

class Blog extends Model
{
    use Translatable;

    public $translatedColumns = ['title'];
}

Usage

//local = en
$blog = Blog::find(1);
$blog->title; // Hello

//local = ar
$blog = Blog::find(1);
$blog->title; // مرحبا

Query

You May use whereLocale to query one of your translatable columns depending on the current locale

//local = en
$blog = Blog::whereLocal('title', 'LIKE', '%hell%')->first();
$blog->title; // Hello

//local = ar
$blog = Blog::whereLocal('title', 'LIKE', '%مرح%')->first();
$blog->title; // مرحبا

Notes

just know that the title property doesn't exist in your table the trait will add it while the model is booting, in other words the sql generated statement will be like below.

when locale is en statementselect title_en as title

when locale is ar statementselect title_ar as title

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

统计信息

  • 总下载量: 1.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固