作者:崔佳丽童鞋 | 来源:互联网 | 2023-09-07 21:20
This is not really a Laravel-Mongodb issue but i think many people using Sentry and Laravel-MongoDb will face this issue .
I use Sentry for authentication. which uses mysql rest everywhere is use mongodb now this package has very nice support for mysql and mongodb relationships .
This is where problem starts
Sentry uses this
1 2
| php
Cartalyst\Sentry\Users\Eloquent\User |
model for its authentication hence we can't do something like
1 2
| php
Sentry::getUser()->messages; |
to do this we have to
refer this
1 2 3 4 5 6 7
| php
use Cartalyst\Sentry\Users\Eloquent\User as SentryUserModel;
class User extends SentryUserModel {
...
...
} |
Now to use awesome mongodb-mysql bridge this package provides we have to
1 2 3 4 5 6 7 8 9 10 11
| php
use Jenssegers\Eloquent\Model as Eloquent;
class User extends Eloquent {
public function items()
{
return $this->hasMany('Item');
}
} |
so i can't do this
1 2
| php
Sentry::getUser()->messages; |
php doesn't have multiple inheritance so i don't know how would i solve this without editing any of vendor packages
pls help
该提问来源于开源项目:jenssegers/laravel-mongodb
I created a separate package if you want to use Sentry: https://github.com/jenssegers/Laravel-MongoDB#sentry