thedevdojo/voyager

Merge two models in one view

Open

#433 opened on 2016年12月22日

GitHub で見る
 (5 comments) (4 reactions) (0 assignees)PHP (11,817 stars) (2,652 forks)batch import
featurehelp wanted

説明

  • Laravel Version: 5.3
  • Voyager Version: 10.5
  • PHP Version: 5.6
  • Database Driver & Version: MySQL

Description:

Let's say, for instance, I have a sales table and a products table. Each sales table contains N products and N services. I'd like to add products to my sales view, so when I create the sale I can add products to it. For now, it can be done by selecting multiple elements from products, but saving it as a string. I can create a sales_products, and a sales_services dropdown input and create the relationships, saving the ids as a string. I'd like to have a table in which I can relate sales_items to the sale and also to tell which type the item is and how many of each I have on the sale, so I can search by the sale_id and find the items related to it.

I can create a table which contains sale_id, item_id and item_type_id, but I would need to create a sale and open another view in order to relate it to the items, and also to create and save one item each time, selecting the sale, the item and the item_type.

I'd like to be able to select multiple items and relate them to the sale and saving them correctly on my database, not as a string, but in the correct way to relate sales_item to the sale in my database.

How can I make it? Is there any way to make it work as expected?

Here's a database model:

Here's an example of the result I'd like to obtain (in this case with services only):

コントリビューターガイド

Merge two models in one view · thedevdojo/voyager#433 | Good First Issue