Ad

Call Specific Value From SQL Table

- 1 answer

Seeking your assistance i've a website laravel based where i need to have multi-lingual support for pages i've the following code to view pages :

@extends('web.layout')
@section('content')

<section class="aboutus-content aboutus-content-one">
  <div class="container">
    <div class="heading">
      <h2>
      <?=$result['pages'][0]->name?>
      </h2>
      <hr style="margin-bottom: 10;">
    </div>`
  <?=stripslashes($result['pages'][0]->description)?>     
  </div>

</section>

    @endsection

the call function

$result['pages'] = DB::table('pages')
                                ->leftJoin('pages_description', 'pages_description.page_id', '=', 'pages.page_id')
                                ->where([['type','2'],['status','1'],['pages_description.language_id',session('language_id')]])
                  ->orwhere([['type','2'],['status','1'],['pages_description.language_id',session('language_id')]])->orderBy('pages_description.name', 'ASC')->get();

database is just like this : https://prnt.sc/rpn9ye

issue is when i switch page language it wont grab arabic language it is stuck to english only to me despite it has the inputs correctly in database.

thank you in advance

Ad

Answer

it is solved by now

public function getPages($request) { $pages = DB::table('pages') ->leftJoin('pages_description', 'pages_description.page_id', '=', 'pages.page_id') ->where([['pages.status', '1'], ['type', 2], ['pages_description.language_id', session('language_id')], ['pages.slug', $request->name]]) ->orwhere([['pages.status', '1'], ['type', 2], ['pages_description.language_id', session('language_id')], ['pages.slug', $request->name]]) ->get(); return $pages; }

i've replaced one in orwhere with direct session id and it worked.

Ad
source: stackoverflow.com
Ad