This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello, I need some help to understand what relation apply in this case.
Table structure:
transactions
id
name
price_type
id
name
currency
id
name
code
property
id
title
property_transactions
id
property_id
transaction_id
price_type_id
currency_id
value # pivot
price # pivot
config_relation_yaml
transactions:
label: pronet.realestate::lang.properties.label.transactions
manage:
list: $/pronet/realestate/models/transaction/columns.yaml
form: $/pronet/realestate/models/property/transaction_fields.yaml
emptyMessage: pronet.realestate::lang.properties.label.no_transactions
defaultSort: name
showSorting: false
pivot:
form: $/pronet/realestate/models/property/transaction_fields.yaml
view:
list: $/pronet/realestate/models/property/transaction_columns.yaml
toolbarButtons: add|remove
The model Property
has this relation:
public $belongsToMany = [
'transactions' => [
'Pronet\RealEstate\Models\Transaction',
'table' => 'pronet_realestate_property_transactions',
'key' => 'property_id',
'otherKey' => 'transaction_id',
'pivot' => ['value', 'price_type_id', 'currency_id'],
],
];
Them I have (example):
for transactions
: "sell", "rent", "project";
for price_type
: "15 days", "30 days", "high season", "low season";
for currency
: "USD", "UYU"
I need to add many "rent" transactions
with different price_type
or currency
and different value
and price
for pivot columns.
But I only can add one "sell" and one "rent" transaction.
I don't know what I missed or what is wrong in my relation.
Any help was very appreciate ;) Thanks (and sorry my english)
Last updated
I think, maybe the key otherKey
, in the relation setting, can be an array, like pivot
key. And them, can validate using multiple columns.
Last updated
I'm thinking another possible solution. But I don't know how to made it with current CMS Form Relations
.
My idea is to have all transactions listed in Property
controller form. Bellow each one, a button to add the price_type
and others pivot columns.
Something like this:
Buy
[Add new price]
+------------+----------------+----------+
| Price type | Value | Currency |
+------------+----------------+----------+
| Cash price | $ 2,150,325.00 | U$S |
+------------+----------------+----------+
Rent
[Add new price]
+-------------+------------+----------+
| Price type | Value | Currency |
+-------------+------------+----------+
| High Season | $ 3,520.00 | U$S |
+-------------+------------+----------+
Project
[Add new Price]
+------------+-------+----------+
| Price type | Value | Currency |
+------------+-------+----------+
| No prices to list | |
+-------------+------+----------+
any help?
1-3 of 3