Hi there, I apologize for these silly questions…
I’m adding a relation render on a Model (Visitas), and this Model displays a data table of another Model (Items) with its own filters toolbar … One of these filters gets the options from another Model (Tracking), which has a column that is related to the first Model (Visitas).
Therefore, one could filter “Items” by selecting the “Trackings” assigned to the current “Visita”.
So, I want to show only “Trackings” that belong to the current “Visita” … I found that optionsMethod helps me with that, so I added it and it works if I ‘hardcode’ the Visita Id in the following method:
In theory I can use the following method in the “Tracking” model:
public function getTracking($visitaId)
{
return self::where('visita_id', $visitaId)->pluck('name', 'id')->toArray();
// right? ...
}
Back in scopes.yaml.
scopes:
tracking:
label: Tracking
modelClass: Autor\Plugin\Models\Tracking
nameFrom: name
conditions: tracking_id = :value
optionsMethod: getTracking
But the question is: how do I pass the Visita’s model Id to it through the Controller? … I haven’t managed to do so! And I’m not sure if that’s the proper way to achieve it either!
Any advise would be greatly appreciated!..