Coder Social home page Coder Social logo

updating an entity about analogue HOT 8 CLOSED

analogueorm avatar analogueorm commented on June 9, 2024
updating an entity

from analogue.

Comments (8)

RemiCollin avatar RemiCollin commented on June 9, 2024

Is Identity a Value Object ? How is it configured in your Entity Map ?

from analogue.

mitjarobic avatar mitjarobic commented on June 9, 2024

IdentityMap.php:

use Analogue\ORM\ValueMap;

class IdentityMap extends ValueMap
{
    protected $attributes = ['first_name', 'last_name'];
}

UserMap.php:

use Analogue\ORM\EntityMap;

class UserMap extends EntityMap {

    protected $table = 'users';

    protected $embeddables = ['identity' => Identity::class];

}

Identity.php:

use Analogue\ORM\ValueObject;

class Identity extends ValueObject {

    public function __construct($firstName, $lastName)
    {
        $this->first_name = $firstName;
        $this->last_name = $lastName;
    }

}

User.php

use Analogue\ORM\Entity;

class User extends Entity {

    public function __construct(Identity $identity)
    {
        $this->identity = $identity;
    }

}

from analogue.

RemiCollin avatar RemiCollin commented on June 9, 2024

Are your column correctly named identity_first_name and identity_last_name in the database ?

from analogue.

mitjarobic avatar mitjarobic commented on June 9, 2024

Yes, it works like it should in the first test... values are inserted... do u not get the error?

from analogue.

RemiCollin avatar RemiCollin commented on June 9, 2024

No, I tried to replicate exactly what you did, i don't get any error. Must be something else. Are your IdentityMap and UserMap classes in the same namespace as the corresponding entity. I suspect one of them is not registered / detected correctly.

from analogue.

mitjarobic avatar mitjarobic commented on June 9, 2024

i pushed my example here https://github.com/mitjarobic/analogue-example

Its a fresh Laravel 5 installation

All classes are in the App namespace. Code should produce the error.

from analogue.

RemiCollin avatar RemiCollin commented on June 9, 2024

Thanks! I'll have a look.

from analogue.

mitjarobic avatar mitjarobic commented on June 9, 2024

did u get the error?

from analogue.

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.