How to get search value from translated table in laravel?











up vote
0
down vote

favorite












I have an activity table with id in it and activity translated table where all the translated dated are store along with activity_id.



I want to get eloquent from this relationship where activity name is given language
below is my migration



 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');
});


i want to search activity with different language and different region and other parameters and return in eloquent










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have an activity table with id in it and activity translated table where all the translated dated are store along with activity_id.



    I want to get eloquent from this relationship where activity name is given language
    below is my migration



     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');
    });


    i want to search activity with different language and different region and other parameters and return in eloquent










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an activity table with id in it and activity translated table where all the translated dated are store along with activity_id.



      I want to get eloquent from this relationship where activity name is given language
      below is my migration



       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');
      });


      i want to search activity with different language and different region and other parameters and return in eloquent










      share|improve this question















      I have an activity table with id in it and activity translated table where all the translated dated are store along with activity_id.



      I want to get eloquent from this relationship where activity name is given language
      below is my migration



       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');
      });


      i want to search activity with different language and different region and other parameters and return in eloquent







      php mysql laravel eloquent






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 15:00

























      asked Nov 4 at 16:40









      Chandra Ghimire

      32




      32





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53142994%2fhow-to-get-search-value-from-translated-table-in-laravel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53142994%2fhow-to-get-search-value-from-translated-table-in-laravel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ