2 DB objects for the same resource
I have two database objects:
• mts_tbl_products_main (a table)
• v_products_main (a view)
Both have a common field: id (product ID).
In my ProductResource.php:
• For public static function table(Table $table): Table, I want to use v_products_main
• For public static function form(Form $form): Form, I want to use mts_tbl_products_main
Is this possible?
Because the view contains much more detailed fields that I want to display in the table, but for editing/creating I only want to use the base table.
2 Replies
Yes, they have a forigenID by the looks of it (product_id) so just build a relationship on the resource to the v_products_main and put the fields in a group field that is the relationship name so then you can just call all the sub fields
i.e.
and call the relationship v_products on the mts_tbl_products_main model.
That would assume product_name is a column on the row for the product.
thank you!