1
There is a 2 tables and a pivot
where she makes the relationship ManyToMany
among the 2 tables.
A table is called Postagems
and the other table is called Departamentos
, so I’m trying to do a related search by department, when I do the search it takes the data of the departments with the articles of the post table and returns to me, thus getting my search.
Behold:
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);
}
So this search returns me this result:
The problem is that my paging only makes the pagination in the variable departamento
that I actually want him to make the pagination in the related table postagems
where there are 3 articles.
How could I make this pagination?
Natan if you have to do the research of
Postagems
then and make a filter for what I could understand, have as you post the two classes?– novic
I found a very quiet way to make pagination with the related tables. See Virgilio 'department' => Department::find($id)->postagems()->paginate($this->department) I have now solved the problem
– Natan Melo