How do you get all the model's children with ajax without getting the child repeatedly?
Currently, I pass the parent model on from the controller to the view like this:
public function index($parent_id)
{
return view('view', ['parent' => Parent::findOrFail($parent_id)]);
}
And then use the parent model to loop the children.
@foreach($parent->children->shuffle() as @child)
// Some code
@endforeach
But this approach is has problem when the parent's children get up to 5,000 records. I'm thinking of fetching the children using ajax one by one or any other more efficient ways.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2L1Haay
via IFTTT
Aucun commentaire:
Enregistrer un commentaire