laravel - get data from table and from relative foreign tables in SQL -


hi have text search input looks matching records in db , gets data table:

let's this:

$q = input::get('items');          $q = "\"" . "($q)" . "\"";          $items = db::table('my_items')->whereraw(              'match(item_name) against(? in boolean mode)',              array($q)          )->get(); 

so items in db textsearch, send result json script updates page items:

return response()->json($items); 

the relations are:

my_item:

public function brand(){          return $this->hasone('app\brand', 'id', 'brand_id');     } 

brand:

public function my_item(){          return $this->belongstomany('app\my_item');      } 

now problem here in 'my_items' table have data ids reference foreign tables. example have 'brand_id' example references 'brands' table can have information regarding brand. example have brand_id = 3 means 'microsoft' in brands table (id = 3, name = microsoft). need not passing brand_id view actual information (name), in case microsoft can put info in item description. but, how can information before sending query? there sort of flag can use in query $items = db::table bla bla foreign?

this way works, db:: method dropped for:

$items = my_item::with('brand')->where('item_name', 'like', "%$q%")->get(); 

this 1 doesn't:

db::table('my_items')::with('brand')->where('item_name', 'like', "%$q%")->get(); 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -