Yes, that actually resolves my doubt. So it returns all translations for Entity. And the method, literally does what it says to do
After driving myself into oblivion trying to make that request return what I was looking for, I finally found the way to get what I want:
This would be the code for the index method (instead of returning a view, I return JSON responses, because my app's design).
public function index(Request $request)
{
if ($request->lang === null) {
$request->lang = 'en';
}
$testimonials = $this->testimonials->allTranslatedIn($request->lang);
foreach ($testimonials as $testimonial) {
$langTestimonials[] = [
'content' => $testimonial->translations->where('locale', $request->lang)->first(),
'media' => [
$this->file->findFileByZoneForEntity('video_poster_' . $request->lang, $testimonial),
$this->file->findFileByZoneForEntity('video_' . $request->lang, $testimonial),
]
];
}
return response()->json(compact('langTestimonials'));
}
And yay, I got what I expected: the translated articles with its matching related media
Another alternative I thought (and I think that would be the straight way to go), would be to create a couple of methods in the TestimonialEloquentRepository, so with a single call within the controller you get similar results.