【发布时间】:2017-11-16 08:05:43
【问题描述】:
我的数据库中有两个表。第一个是行业,第二个是行业语言。
行业表
Schema::create('industries', function (Blueprint $table) {
$table->increments('id');
$table->string('industry_name', 100);
$table->integer('language_id')->default(1);
$table->timestamps();
});
Industry_Languages 表
Schema::create('industry_languages', function (Blueprint $table) {
$table->increments('id');
$table->integer('industry_id');
$table->string('industry_name', 200);
$table->integer('language_id');
$table->timestamps();
});
这是我的工业控制器
public function store(Request $request)
{
$industry = new Industry();
$industry->industry_name = $request->industryName;
$industry->save();
return response()->json($industry);
}
此函数只会将数据存储到语言 id = 1 的行业表中,但我也想将其存储到语言 id = 2 的行业语言表中(因为我的数据库中有一个语言表,其中包含 2 行数据:'印度尼西亚','英语')
示例:如果我在行业名称字段中输入“光环”,它将在行业名称字段中存储为“光环”,在语言ID字段中输入“1”,然后它也会存储到我的行业语言表中在行业名称字段中作为“你好”,在语言 ID 字段中作为“2”
我在翻译行业表格中的请求时遇到问题。
我尝试过使用Laravel google-translate,但是没有用
【问题讨论】:
标签: php laravel google-translate