Skip to content
Advertisement

Tag: orm

Symfony OneToMany Assiociations not working

I have Product entity and ProductAttachment entity. One product should be able to have many attachments. I Used Doctrine mapping OneToMnay – ManyToOne but everytime i get product, it has empty $files collection ProductAttachment Entity Product Entity Am i Missing anything? When i call this is what i get Answer The problem is Doctrine’s lazy loading of collections, which is

symfony @oneToMany relation returns only last object in collection

I have a situation and not really sure what I’m doing wrong. in Sumfony 3.3 I’ve created a relation between entity Page and Language, where Page is related to multiple Languages, and when I search for a Page and get Page object but property Languages returns collection with only last Language object. No matter how many objects are there in

Laravel – Eloquent – Dynamically defined relationship

Is it possible to set a model’s relationship dynamically? For example, I have model Page, and I want to add relationship banners() to it without actually changing its file? So does something like this exist: Or something similar? As they are fetched using the magic methods anyway, perhaps I can add the relationship dynamically? Thanks! Answer I’ve added a package

Type hinting for the model objects of Eloquent ORM

I haven’t used laravel yet, but watching the tutorials on youtube left me with a question to type hinting, that is really important to me. Now I have read here Type Hinting Eloquent Models and here Eloquent ORM Code Hinting in PhpStorm but neither addresses the following problem: now lets say movie has a name, id, length, author all those

Virtual fields with Cakephp 3

I need to have a virtual property in my user entity. I followed the CakePHP book. UserEntity.php In a controller I followed exactly the book and I only get a null value. Answer According to @ndm, the problem was due to a bad file naming. I named the user entity class UserEntity.php. The CakePHP name conventions says that: The Entity

Get primary key of Eloquent model instance

I’m happy enough to work on a project with (not) very consistent column names in our MySQL database. We have camelCase, PascalCase, ‘Id’, ID and it’s driving me nuts. I’ve decided to start using Eloquent in our application (which is NOT Laravel). I would love to have a method of receiving the value of the primary key easily without knowing

Advertisement