如何从Laravel中的翻译表中获取搜索值?

时间:2018-11-04 16:40:37

标签: php mysql laravel eloquent

我有一个带有ID的活动表和一个活动翻译表,其中所有已翻译的日期都与activity_id一起存储。

我想从这种关系中变得雄辩,这种关系中给活动名称指定了语言 下面是我的迁移

 Schema::create('activity_types', function (Blueprint $table) {
 $table->increments('id');
 $table->boolean('flag');
 $table->timestamps();
 });
 Schema::create('activity_type_translations', function (Blueprint $table) {
 $table->increments('id');
 $table->string('name');
 $table->string('slug');
 $table->string('description');
 $table->integer('activity_type_id')->unsigned();
 $table->string('locale')->index();
 $table->timestamps();
 $table->unique(['activity_type_id','locale']);
 $table->foreign('activity_type_id')->references('id')->on('activity_types')->onDelete('cascade');
 });
 Schema::create('activities', function (Blueprint $table) {
 $table->increments('id');
 $table->string('code');
 $table->integer('country_id')->unsigned();
 $table->integer('activity_type_id')->unsigned();
 $table->integer('region_id')->unsigned();
 $table->string('feature_image');
 $table->string('route_map')->nullable();
 $table->boolean('flag');
 $table->timestamps();
 $table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
 $table->foreign('activity_type_id')->references('id')->on('activity_types')->onDelete('cascade');
 $table->foreign('region_id')->references('id')->on('regions')->onDelete('cascade');
 });
 Schema::create('activity_translations', function (Blueprint $table) {
 $table->increments('id');
 $table->string('name');
 $table->string('duration');
 $table->string('trek_duration');
 $table->string('trek_grade');
 $table->string('accomodation');
 $table->string('meal');
 $table->string('max_altitude');
 $table->string('best_time');
 $table->string('max_group_size');
 $table->string('individual_cost');
 $table->string('group_cost');
 $table->text('summary');
 $table->text('overview');
 $table->text('itinenary');
 $table->text('important_note');
 $table->text('cost_include');
 $table->text('cost_exclude');
 $table->text('equipment_checklist');
 $table->text('before_you_go');
 $table->enum('trip_status', ['booking open', 'join a group']);
 $table->integer('activity_id')->unsigned();
 $table->string('locale')->index();
 $table->timestamps();
 $table->unique(['activity_id','locale']);
 $table->foreign('activity_id')->references('id')->on('activities')->onDelete('cascade');
 });

我想用不同的语言,不同的地区和其他参数搜索活动并雄辩地返回

0 个答案:

没有答案