Comments (7)
I had the same issue, and I tried to add the inverse of relation on my child item resource.
For the Posts example, I have the following on my Post resource.
BelongsTo::make(__('User'), 'user', User::class),
This fixed the issue.
from laravel-nova-nested-form.
Yes, it's working fine after inverse relations.👍
from laravel-nova-nested-form.
Did you set this in yout BotWhiteListIp model?
protected $primaryKey = 'bot_white_list_id';
from laravel-nova-nested-form.
bot_white_list_id
is foreign key of bot_white_lists table, i think it should auto fill from parent resource model on save update?
this is table structure
mysql> DESCRIBE bot_white_lists;
+-----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| homepage_url | varchar(255) | YES | | NULL | |
| agent | varchar(255) | NO | | NULL | |
| created_at | datetime | NO | | NULL | |
| updated_at | datetime | YES | | NULL | |
+-----------------+------------------+------+-----+---------+----------------+
mysql> describe bot_white_list_ips;
+-------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+------------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| bot_white_list_id | int(10) unsigned | NO | MUL | NULL | |
| ip | varchar(128) | NO | | NULL | |
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | NO | | NULL | |
+-------------------+------------------+------+-----+---------+----------------+
i have added hasMany relation in BotWhiteList
model of BotWhiteListIps
model, and the NestedForm
field has attached in BotWhiteList
resource, so it should auto fill when BotWhilteList
is create. but this is returning error
SQLSTATE[HY000]: General error: 1364 Field 'bot_white_list_id' doesn't have a default value (SQL: insert into bot_white_list_ips
(ip
, updated_at
, created_at
) values (127.0.0.1, 2019-02-17 09:41:20, 2019-02-17 09:41:20))
Auto populated items is updating fine but when i add new item then error is show up.
Is there way, i can fill bot_white_list_id
value before create or update for add new items
from laravel-nova-nested-form.
OK, are you able to fetch your related bot_ips outside of this package? I'm not sure but I think you should set your relationship as follows:
public function bot_ips () {
return $this->hasMany(BotWhiteListIp::class, 'bot_white_list_id', 'id');
}
from laravel-nova-nested-form.
thank you for your reply, i think, the relationship is already setup accordingly
foreignKey, localKey is auto populating by naming convention
The relation filed is working fine with Nova HasMany field, but it's providing option on view page, but i would like to add more option in same form
from laravel-nova-nested-form.
@mortezarajabi thanks man!
from laravel-nova-nested-form.
Related Issues (20)
- Global search is broken, when using NestedForm HOT 4
- Changing text when there is no data HOT 2
- Multiple subresources are created when Observer saves main resource again HOT 2
- How to pass a parameter to child nested form? HOT 7
- Help text is not displayed HOT 6
- The nested relationship model is often not yet available in the parent object observer created() method
- What's the best way to translate things in LNNF HOT 2
- Second nested form display index incorrect
- Nested form validation not working. HOT 1
- Nested Form not working after update laravel 7 and nova 3
- defining the inverse - Whats's wrong? HOT 2
- Touch related items
- Is there anyway to override file field
- Support for Laravel Nova Advanced media library HOT 2
- Slow result rendring while using with BelongsTo field
- Support for Laravel Nova 4 HOT 15
- How to hide relationship column
- Question: is it possible to show related resources not only when editing, but when viewing main resource too?
- Trying to get property 'resourceClass' of non-object
- The Add new Record button is not adding the correct index
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-nova-nested-form.