How can I change the assumed table name in a relation manager?

Hi everyone, I have a belongsToMany relation between a medications table and a presentation table. The pivot table includes extra information so I called it medication_variation. I created a relation manager but filament is looking for a table called medication_presentation. How can I change it ?
3 Replies
devfaysal
devfaysal2y ago
How did you define the relationship in the Model? If the relationship works fine, then Filament should work fine. First check somewhere else that relationship working correctly. The easiest way to test is the web.php in the routes folder. define a test route and add code something like this:
$medication = Medication::first();
dd($medication->medication_variation);
$medication = Medication::first();
dd($medication->medication_variation);
guitarnerd_
guitarnerd_OP2y ago
Thanks @devfaysal The problem was not having defined the inverse relationship
salma
salma2y ago
you can also change the model name to "medication_presentation" and define the table name in the model as : protected $table=medication_variation;

Did you find this page helpful?