2 개의 객체가 있습니다. 첫 번째 객체는 객체 작업의 주석을 검색하고 두 번째 객체는 객체 성취도의 주석을 검색합니다. 주석 목록이 들어있는 단일 테이블에 결과를 표시하려고합니다. 보기에서laravel 하나의 배열에있는 두 객체의 결과
$posts1 =\DB::table('posts')
->select('posts.*', 'profils.nom_profil', 'works.titre', 'profils.imagelogo', 'works.description', 'works.like', 'works.nlike')
->join('works', 'posts.work_id','=','works.id')
->join('profils', 'posts.profil_id','=','profils.id')
->where('works.profil_id',$id)
->orderBy('posts.id', 'desc')
->paginate(10);
$posts2 =\DB::table('posts')
->select('posts.*', 'profils.nom_profil', 'achievs.titre', 'profils.imagelogo', 'achievs.description', 'achievs.like', 'achievs.nlike')
->join('achievs', 'posts.achiev_id','=','achievs.id')
->join('profils', 'posts.profil_id','=','profils.id')
->where('achievs.profil_id',$id)
->orderBy('posts.id', 'desc')
->paginate(10);
:
이@foreach($posts as $post)
.
.
.
@endforeach
할 - 먼저 그들에게 컬렉션을 만들> 수() 모두 쿼리를, 당신은 병합 할 수 있습니다. – phobia82