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

Compatibility with laravel-mongodb ? #3

Closed
awupoh opened this issue Jan 6, 2015 · 3 comments
Closed

Compatibility with laravel-mongodb ? #3

awupoh opened this issue Jan 6, 2015 · 3 comments

Comments

@awupoh
Copy link

awupoh commented Jan 6, 2015

hi
I just found this library when i was trying to implement something similar. Great stuff, thanks.

In fact, I am new to laravel and eloquent.
As I am using mongodb , i also found this mongodb version eloquent https://github.com/jenssegers/laravel-mongodb

However, when I try to use SingleTableInheritanceTrait to that 'Moloquent' I have to make two changes in order to make it work:

1.at line 171 of SingleTableInheritanceTrait.php

$classType = isset($attributes->$typeField) ? $attributes->$typeField : null;
to
$classType = isset($attributes[$typeField]) ? $attributes[$typeField] : null;

this one i guess is something related to 'mongo' as it will return pure array, i didn't have time to check with 'mysql'

2.at line 195 of SingleTableInheritanceTrait.php

return $this->getTable() . '.' . static::$singleTableTypeField;
to
return static::$singleTableTypeField;

same thing here as the query column key needs to be the field name itself without 'table' name

Any thought about this?

@jonspalmer
Copy link
Owner

I think test cases and fixes would be valuable. We need to support mysql not clear what the right way is to make the switch.

@Kaylakaze
Copy link

Well, a brute force way would be to check the database and see if it's MongoDB and branch accordingly. Or, if that's too specific to MongoDB, you can add a user set variable $includeTableNameInColumn. For the first issue, I think -> is technically incorrect and works only by accident (the Eloquent method that your newFromBuilder overrides takes an array as param 1, not an object ). https://laravel.com/api/5.2/Illuminate/Database/Eloquent/Model.html#method_newFromBuilder

@jonspalmer
Copy link
Owner

Closing out a long ago asked question. I don't have time to investigate what it takes to support Mongo. A PR with test cases would be happily accepted provided they maintain existing support.

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