Skip to content
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

Allow sideloading to check for uniqueness using other identifiers than id #1

Open
esbenp opened this issue Aug 30, 2015 · 3 comments
Open

Comments

@esbenp
Copy link
Owner

esbenp commented Aug 30, 2015

To check if a sideloaded resource already exists in the global scope, it should be allowed to check using something else than id

@gruz
Copy link

gruz commented Apr 24, 2017

Hi. I use a preexisting database with uuid primary indexes like b504fabe-5782-4b62-89bd-f33f1d78449a instead of numeric indexes.

Currently Optimus is hardcoded to use index name id and index type of integer.

It's very easy to fix.
So lines like return (int) Utility::getProperty($entry, 'id'); (e.g. https://github.com/esbenp/architect/blob/master/src/ModeResolver/IdsModeResolver.php#L41 ) should be changed to return Utility::getProperty($entry, $entry->getKeyName());

And lines like
return $objectOrArray->{$property};
e.g. https://github.com/esbenp/architect/blob/master/src/Utility.php#L21
should be replaced with
return $objectOrArray->getAttributes()[$property];

I don't understand why the (int) is a must in your code. Anyway, we can define it by the Model property $incrementing

Is there any chance you are going to fix it soon?

Thank you very much!

@akito85
Copy link

akito85 commented Apr 25, 2017

@gruz you can do a pull request ;P

@gruz
Copy link

gruz commented Apr 25, 2017

Submitted a pull request #5
I don't think it covers all possible situations, I know laravel not well enough. But in my case it works and I believe is a good start for your to fix other possible issues here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants