承接 onurkacmaz/laravel-model-translate 相关项目开发

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

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

onurkacmaz/laravel-model-translate

最新稳定版本:v1.0.0

Composer 安装命令:

composer require onurkacmaz/laravel-model-translate

包简介

This package allows model translation. It is like Symfony's gedmo translation package.

README 文档

README

Latest Version on Packagist Total Downloads

This package allows model translation. It is like Symfony's gedmo translation package. It is very easy to use. You can use it in your models or controllers. Basically, it is a trait that you can use in your models. It will automatically create translation records of the fields you specify in the model. It will show the translation according to the registered locale. When creating or updating it will use the registered locale and will process that record. The main table pairs with "foreign_id" and "model namespace" to the translations table.

Installation

You can install the package via composer:

composer require onurkacmaz/laravel-model-translate
php artisan vendor:publish --provider="Onurkacmaz\LaravelModelTranslate\LaravelModelTranslateServiceProvider" --tag=config
php artisan vendor:publish --provider="Onurkacmaz\LaravelModelTranslate\LaravelModelTranslateServiceProvider" --tag=migrations
php artisan migrate

Usage

Trait

use Onurkacmaz\LaravelModelTranslate\Traits\Translatable;

class Blog extends Model
{
    use Translatable;

    // You can define which fields will be translated
    public function getTranslatable(): array
    {
        return ['title', 'content'];
    }
}

Class Based Usage

use Onurkacmaz\LaravelModelTranslate\Traits\Translatable;

class TestController extends Controller
{
    public function index() {
        $translate = new LaravelModelTranslate();
        $translate->setColumns(['title', 'content']);
        $translate->setModel($blog);
        $translate->setLocale('en');
        $translate->translate();
        
        // or
        
        $translate = new LaravelModelTranslate($blog, ['title', 'content'], 'en');
        $translate->translate();
    }
}

Static Usage

use Onurkacmaz\LaravelModelTranslate\Traits\Translatable;

class TestController extends Controller
{
    public function index() {
        $translate = LaravelModelTranslate::make()
            ->setModel($account)
            ->setLocale('en')
            ->setColumns(['title', 'content'])
            ->translate();
    }
}

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email kacmaz.onur@hotmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固