Giter Site home page Giter Site logo

Duplicate keys detected about people HOT 11 CLOSED

laravel-enso avatar laravel-enso commented on June 7, 2024
Duplicate keys detected

from people.

Comments (11)

mauthi avatar mauthi commented on June 7, 2024

2 other things:

  • if person belongs to 1..n user e-mail should not be editable (at the moment it is readonly if person belongs to exact 1 user, if person belongs to >1 user it is not readonly)
  • edit user in person edit form should not hidden if there is one than 1 user connected

from people.

aocneanu avatar aocneanu commented on June 7, 2024

We got to the point where we needed in our applications a way to handle people that don't have access in the app at some point, but may have in the future.

Once the People structure was created we wanted to normalize the database. Before having People, the personal details for users were kept in the users table.

Our intention is to have a One to One relation - the Person model has a user() relation, without an s

The implementation does not allow creating more than one user per person (from the interface) unless you do something "under the hood".

from people.

mauthi avatar mauthi commented on June 7, 2024

Ok. So the only missing thing is why the id of user is shown in people table and not the id of person.

from people.

aocneanu avatar aocneanu commented on June 7, 2024

the query behind PeopleTable should be:

return Person::select(\DB::raw(
                'people.*, people.id as "dtRowId", CASE WHEN users.id is null THEN 0 ELSE 1 END as "user"'
            ))->leftJoin('users', 'people.id', '=', 'users.person_id');

people.* will select the id of the person. There is no user.id in this select.

the request response as I see it is:

{id: 1, company_id: 115, title: "Mr", name: "Administrator", appellative: "Admin", uid: "admin",…}
appellative: "Admin"
birthday: "24-10-2018"
company_id: 115
created_at: "05-10-2017"
created_by: null
dtRowId: 1
email: "[email protected]"
id: 1
name: "Administrator"
obs: "13132222"
phone: "456"
position: "test"
title: "Mr"
uid: "admin"
updated_at: "2019-01-25 10:47:10"
updated_by: 1
user: 1

where user:1 is a boolean flag.

Could you be more precise?

from people.

mauthi avatar mauthi commented on June 7, 2024

Output:
screenshot 2019-01-26 14 44 41

Response for the output above:
screenshot 2019-01-26 14 45 57

Really strange...

from people.

aocneanu avatar aocneanu commented on June 7, 2024

what's strange? You have two people, one with the id of 32 and one with 33.

from people.

mauthi avatar mauthi commented on June 7, 2024

from people.

mauthi avatar mauthi commented on June 7, 2024

from people.

aocneanu avatar aocneanu commented on June 7, 2024

1,2,3,4 is the current number :D

from people.

aocneanu avatar aocneanu commented on June 7, 2024

can we close this?

from people.

mauthi avatar mauthi commented on June 7, 2024

from people.

Related Issues (11)

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.