Comments (7)
Hi @mgazelle,
I appreciate your thought, but we have to integrate it manually after code generation.
Different developers will have different thoughts over this as we have facility to edit our module field after creation.
Let me know if you have a good plan for implementation strategy. I would appreciate that.
Best Regards,
from laraadmin.
I have changed this on my site to auto create the migration blocks you would create by hand in a migration file. All you have to do, is translate the field definition in the proper syntax of a migration file (Schema::create) and then append the foreign keys at the end.
I do not store the field definition in a table as mentioned in another issue post. I just translate the fields in proper laravel code which will adhere to Laravel docs and definitions.
I do not think personally a generator should write definitions back into the app database.
Another approach would be to reverse the DB schema. This way you create the DB and you are done with the rest.
from laraadmin.
Check inbuilt migrations.
Can we use relationship manual way like that ?
File: 2014_12_01_000000_create_uploads_table.php
if (Schema::hasTable('users')) {
Schema::table('uploads', function ($table) {
$table->foreign('user_id')->references('id')->on('users');
});
}
It is also possible to reverse migrate this by putting similar syntax at end of up() method.
Let me know.
from laraadmin.
@gdbhosale
This is in fact the Laravel way doing it. Relationship is in my opinion the most critical feature in the whole package. This would improve the package a lot. My suggestion would be:
- check if the relationship is implemented in the DB (from the migration file or the module definition)
- if not check the migration file to make sure it has not been appended
- generate a new laravel migration file including just the foreign keys in the up method
If the relation is defined during the generation of the module then just append it to the up method
from laraadmin.
@mgazelle @slozano95 I have completed with auto foreign key setting through Migrations as well as GUI. We can as well shift foreign keys from one table to another without fuss.
I am not very sure about way i have implemented it. Please go through the code.
Let me know your view. Hey @mgazelle You were quite right about this 👍
Please report problems soon if they exists.
============ Module::create_field_schema (line 296) ============
$foreign_table_name = str_replace("@", "", $field->popup_vals);
if($update) {
$var = $table->integer($field->colname)->unsigned()->change();
if($field->defaultvalue == "" || $field->defaultvalue == "0") {
$var->default(1);
} else {
$var->default($field->defaultvalue);
}
$table->dropForeign($field->module_obj->name_db."_".$field->colname."_foreign");
$table->foreign($field->colname)->references('id')->on($foreign_table_name);
} else {
$var = $table->integer($field->colname)->unsigned();
if($field->defaultvalue == "" || $field->defaultvalue == "0") {
$var->default(1);
} else {
$var->default($field->defaultvalue);
}
$table->foreign($field->colname)->references('id')->on($foreign_table_name);
}
Thank you guys...
from laraadmin.
How to u se this? Do you plan to implement manage relations n:m (many to many) via GUI? Very useful will be also show related records in record view. Eg. Organization has many (3) Contacts. I see Organization and below section "Related Contacts" with this 3 records - its fundamental to CRM.
from laraadmin.
Hi @mgazelle,
Foreign key linking with respective table is automatically handled by Custom Migrations.
You only need to write methods in Models.
Best Regards,
from laraadmin.
Related Issues (20)
- Images are not display with ?s=30 parameter
- ErrorException in Builder.php line 1185: HOT 2
- REST API
- @la_input does not work for me HOT 1
- dropdown but using integer as value HOT 2
- Getting Error while trying to save any new record in any module
- Error 404 when navigating to login page and others HOT 1
- Current project status HOT 10
- Can able to install LaraAdmin in cPanel?
- Error When Trying To Start Installation HOT 2
- Getting Error while trying to install laraadmin HOT 1
- How to override default view? HOT 1
- Model table within a different model HOT 1
- All the pages for Default modules deleted/changed when I click Generate Module
- any update here.i am also getting erro
- Moving Proejct From one server to another Image issue HOT 1
- Need to use laraadmin with latest versions of laravel HOT 1
- error when installing HOT 1
- configuration issue
- Fronend Images Loading issue >> net::ERR_CONNECTION_CLOSED HOT 1
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 laraadmin.