-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating foreign-constraint and/or foreign-relation properties from command line #109
Comments
Please upgrade to the latest version. In order to create a field from the command line you'll have to change the format to this ``-fields="name:fooModel;is-nullable:true;data-type:varchar;foreign-relation:assets#hasMany#App\Models\Asset|category_id|id" Note: you'll need to separate the relation parts by |
So using your suggested fields argument should result in the following resource file? What about the second part of my issue, namely generating a foreign-constraint from the command line?
|
I’ll check on the foreign constrain when time permits. However, it may be easier for you to add the relations by editing the json file directly. |
Ok, thanks for that. |
Greetings Sir. Could you give me artisan command to generate code for the following tables with foreign key relations: table 3: addDoc table 4: searchcriteria |
Before you submit an issue please read this
This repository is only for reporting bugs or issues. If you need support, please use Stack Overflow using laravel-code-generator tag (https://stackoverflow.com/questions/tagged/laravel-code-generator)
Please provide us with details by completing the following requirements. Issues with not enough info are likely to be closed without resolution.
Environment:
Laravel-Code-Generator Version: 2.2.12
Laravel Version: 5.5.44
Description:
I'm not sure if this is a bug just in the documentation (since I couldn't find an example, or figure out how to do it) or somewhere in actual code, but how do I go about specifying foreign-relation and/or foreign-constraint values from the command line?
Using the relations parameter works as it should, generating a belongsTo relation:
Per the docs, "When creating hasOne() or belongsTo() relations, it be best to define them at the field level using the foreign-relation option."
How do I add the above relation onto the fooModel field on fooOwnedModel when generating it at the command line. The following doesn't generate the relation I'm expecting:
php artisan resource-file:append fooOwnedModel --fields="name:fooModel;is_nullable:true;data_type:varchar;foreign_relation:name=fooModel:type=belongsTo:params|\\App\\FooModel|id:field|id"
?Steps/Commands To Reproduce:
php artisan resource-file:append fooOwnedModel --fields="name:fooModel;is_nullable:true;data_type:varchar;foreign_relation:name=fooModel:type=belongsTo:params|\\App\\FooModel|id:field|id"
Content Of The Resource-File:
The text was updated successfully, but these errors were encountered: