Giter Site home page Giter Site logo

Comments (7)

schmunk42 avatar schmunk42 commented on June 28, 2024

Which is a method that calls the model EmpresaRegimen that doesn't exist. As far as I am concerned with standards, glue tables like that (only empresa_id and regimen_id being the fields) should not have model file. Or am I wrong in such interpretation?

Basically you're right, if you generate your models and CRUDs manually you can work around this issue and you do not have to generate models for the glue (pivot) tables.
But on the other hand you have to prepare your controllers to handle the saving of the related records. Yii 2 comes equipped with a link() method which does most of the job for you, see also http://stackoverflow.com/a/26781976/291573

In giiant I decided to implement the generation of CRUDs in a very basic and generic way, which includes also the generation of CRUDs for the pivot tables.
The reason behind this decision is, that it is very hard to automate the generation of input and the saving of related data.

So for now, you'd have to generate a model for your pivot tables and then regenerate the CRUDs.

But I'll keep this issue open - it's on the roadmap to improve this.

from yii2-giiant.

ramoscarlos avatar ramoscarlos commented on June 28, 2024

In giiant I decided to implement the generation of CRUDs in a very basic and generic way, which includes also the generation of CRUDs for the pivot tables.

I see. Then, I am going to stick to the use of models for the pivot tables.

One question, though. Is the model the only thing neccesary or do I need to create a controller and views associated to the pivot tables?

Regards.

from yii2-giiant.

schmunk42 avatar schmunk42 commented on June 28, 2024

You need everything, but Giiant should do the whole job for you.
Please make sure you have a composite PK for your pivot table.

Usually I am creating the CRUD in a separate folder or module and don't them afterwards.
All customization is done through providers btw

Von meinem iPad gesendet

Am 17.02.2015 um 04:58 schrieb Carlos Ramos [email protected]:

In giiant I decided to implement the generation of CRUDs in a very basic and generic way, which includes also the generation of CRUDs for the pivot tables.

I see. Then, I am going to stick to the use of models for the pivot tables.

One question, though. Is the model the only thing neccesary or do I need to create a controller and views associated to the pivot tables?

Regards.


Reply to this email directly or view it on GitHub.

from yii2-giiant.

schmunk42 avatar schmunk42 commented on June 28, 2024

I'll try to setup a demo application to make things more clear.

from yii2-giiant.

ramoscarlos avatar ramoscarlos commented on June 28, 2024

Thanks for the info!

Please make sure you have a composite PK for your pivot table.

It seems that I lack more knowledge than what I thought at first u.u. I have not declared the composite key so far. In my migration, I have a foreign key relation to both tables, as:

$this->addForeignKey('empresa__regimen__e', 'empresa_regimen', 'empresa_id', 'empresa', 'id', 'RESTRICT', 'CASCADE');
$this->addForeignKey('empresa__regimen__r', 'empresa_regimen', 'regimen_id', 'regimen', 'id', 'RESTRICT', 'CASCADE');

Then I would need to declare the primary key as:

$this->addPrimaryKey('empresa_regimen_pk', 'empresa_regimen', 'empresa_id, regimen_id');

You need everything, but Giiant should do the whole job for you.
All customization is done through providers btw

So, I have to use the code generator (Giiant) to scaffold a lot of the code and then leave the base class alone forever. And all the database interactions I need would be done on the model that inherits from the base class, where I will start to use data providers to, well, provide the records.

So much new information. I think I have to read a Yii2 book before proceeding further.

And the demo would be more than welcome.

from yii2-giiant.

schmunk42 avatar schmunk42 commented on June 28, 2024

Here's the temporary demo:
http://playground-ee59a477-1.schmunk.cont.tutum.io:49160
admin/admin

Source:
https://github.com/phundament/playground

But I still need to review your latest comment...

from yii2-giiant.

schmunk42 avatar schmunk42 commented on June 28, 2024

New demo URL see: https://github.com/phundament/playground

Closing issue, please let me know if you've still have questions.

from yii2-giiant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.