I want to take 3 different schema tables, each schema requires a join with a params table, so here I am trying to take one and merge, but I think that method is not effective and makes old data load, this my code
$tabel1 = DB::table('schema1.vendors AS ven')
->orderBy('created_at','desc')
->leftJoin('schema1.admin_params AS ap','ap.admin_param_uuid','=','ven.product_type')
->select('ven.*','ap.description','ap.param_value')
->where('ven.deleted_by',null)
->where('ap.deleted_by',null)
->get();
$tabel2 = DB::table('schema2.vendors AS ven')
->orderBy('created_at','desc')
->leftJoin('schema2.admin_params AS ap','ap.admin_param_uuid','=','ven.product_type')
->select('ven.*','ap.description','ap.param_value')
->where('ven.deleted_by',null)
->where('ap.deleted_by',null)
->get();
$merged = $tabel1->merge($tabel2)->sortByDesc('created_at');
I feel that my code is too heavy when loading, is there any suggestion to make my code simplified? because there will be 5 different schemas, but still the table being called is the vendor
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/38cd4du
via IFTTT
Aucun commentaire:
Enregistrer un commentaire