There are 2 tables and a pivot
where it makes the ManyToMany
relationship between 2 tables .
A table is called Postagems
and the other table is named Departamentos
, so I'm trying to do a related search by department, when I do the search it takes the department data with the articles from the posting table and returns it to me , thus becoming my search.
See:
public function searchDepartamentoGet($id)
{
$data = array(
'titulo' => 'Artigo Por Departamento',
'departamento' => Departamento::with('postagems')
->where('id', $id)
->paginate($this->departamento)
);
return view('frontend.artigo.departamentos' , $data);
}
Then this search returns this result:
The problem is that my pagination only does pagination on the variable departamento
that I actually want it to paginate on the related table postagems
where there are 3 articles .
How could you make this paging?