Laravel Nova属于多个相同模型

时间:2019-11-08 16:14:01

标签: laravel laravel-nova

我有以下架构:

mysql> describe event_state;
+---------------------+---------------------+------+-----+---------+----------------+
| Field               | Type                | Null | Key | Default | Extra          |
+---------------------+---------------------+------+-----+---------+----------------+
| id                  | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| event_id            | bigint(20) unsigned | NO   | MUL | NULL    |                |
| state_id            | bigint(20) unsigned | NO   | MUL | NULL    |                |
| gender              | varchar(191)        | NO   |     | NULL    |                |
| value               | decimal(8,2)        | NO   |     | NULL    |                |
| value_type          | varchar(191)        | NO   |     | NULL    |                |
| display_measurement | varchar(191)        | NO   |     | NULL    |                |
| deleted_at          | timestamp           | YES  |     | NULL    |                |
| created_at          | timestamp           | YES  |     | NULL    |                |
| updated_at          | timestamp           | YES  |     | NULL    |                |
+---------------------+---------------------+------+-----+---------+----------------+
10 rows in set (0.01 sec)



mysql> describe events;
+-------------+---------------------+------+-----+---------+----------------+
| Field       | Type                | Null | Key | Default | Extra          |
+-------------+---------------------+------+-----+---------+----------------+
| id          | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| name        | varchar(191)        | NO   | UNI | NULL    |                |
| category_id | bigint(20) unsigned | NO   | MUL | NULL    |                |
| created_at  | timestamp           | YES  |     | NULL    |                |
| updated_at  | timestamp           | YES  |     | NULL    |                |
| deleted_at  | timestamp           | YES  |     | NULL    |                |
+-------------+---------------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)

mysql> describe states;
+------------+---------------------+------+-----+---------+----------------+
| Field      | Type                | Null | Key | Default | Extra          |
+------------+---------------------+------+-----+---------+----------------+
| id         | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| name       | varchar(191)        | NO   | UNI | NULL    |                |
| created_at | timestamp           | YES  |     | NULL    |                |
| updated_at | timestamp           | YES  |     | NULL    |                |
| deleted_at | timestamp           | YES  |     | NULL    |                |
+------------+---------------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

event_state表中,我可以具有相同的event_id和state_id,并附加了不同的性别(男性或女性)。 Larvel Nova不允许通过资源中的BelongsToMany进行此操作。

  1. 有没有办法在laravel Nova中完成这项工作(它说它已经附上了)
  2. 如果没有,是否有更好的方法来完成我想做的事?

0 个答案:

没有答案