Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
635 stars 197 forks source link

Error when getting edge of releationship. #63

Closed piyushpatil027 closed 9 years ago

piyushpatil027 commented 9 years ago

hi Abed Halawi,

Hope you are doing great.I am using your Neo4j eloquent in Laravel.When i getting edge of releationship then it is giving below error.Can you help me how it should remove this error.

exception 'ErrorException' with message 'Argument 3 passed to Vinelab\NeoEloquent\Eloquent\Edges\Relation::construct() must be an instance of Vinelab\NeoEloquent\Eloquent\Model, null given, called in /usr/share/nginx/html/cardiomeet/vendor/sgpatil/neoeloquent/src/Vinelab/NeoEloquent/Eloquent/Relations/HasOne.php on line 124 and defined' in /usr/share/nginx/html/cardiomeet/vendor/sgpatil/neoeloquent/src/Vinelab/NeoEloquent/Eloquent/Edges/Relation.php:128 Stack trace: #0 /usr/share/nginx/html/cardiomeet/vendor/sgpatil/neoeloquent/src/Vinelab/NeoEloquent/Eloquent/Edges/Relation.php(128): Illuminate\Exception\Handler->handleError(4096, 'Argument 3 pass...', '/usr/share/ngin...', 128, Array) #1 /usr/share/nginx/html/cardiomeet/vendor/sgpatil/neoeloquent/src/Vinelab/NeoEloquent/Eloquent/Relations/HasOne.php(124): Vinelab\NeoEloquent\Eloquent\Edges\Relation->construct(Object(Vinelab\NeoEloquent\Eloquent\Builder), Object(User), NULL, 'HAS_PUSHNOTIFIC...', Array, true) #2 /usr/share/nginx/html/cardiomeet/vendor/sgpatil/neoeloquent/src/Vinelab/NeoEloquent/Eloquent/Relations/HasOne.php(136): Vinelab\NeoEloquent\Eloquent\Relations\HasOne->getEdge(NULL) #3 /usr/share/nginx/html/cardiomeet/app/models/PushNotification/PushNotification.php(55): Vinelab\NeoEloquent\Eloquent\Relations\HasOne->edge() #4 /usr/share/nginx/html/cardiomeet/app/models/PushNotification/PushNotification.php(73): PushNotification\PushNotification->getPushNotificationsNode('257809') #5 /usr/share/nginx/html/cardiomeet/app/Repository/PushNotification/PushNotificationRepositary.php(39): PushNotification\PushNotification->saveImeiAndAndroidAPIKey('257809') #6 /usr/share/nginx/html/cardiomeet/app/controllers/RestController/RestPushNotificationController.php(57): Repository\PushNotification\PushNotificationRepositary->saveImeiAndAndroidAPIKeyAllUserInRepo(Array) #7 /usr/share/nginx/html/cardiomeet/app/controllers/RestController/RestPushNotificationController.php(74): RestPushNotificationController->setPushNotificationAPIKey() #8 /usr/share/nginx/html/cardiomeet/app/controllers/RestController/RestPushNotificationController.php(46): RestPushNotificationController->setFunctionName() #9 /usr/share/nginx/html/cardiomeet/app/controllers/RestController/RestPushNotificationController.php(37): RestPushNotificationController->getJsonArray() #10 [internal function]: RestPushNotificationController->pushnotification('257809') #11 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array) #12 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('pushnotificatio...', Array) #13 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(RestPushNotificationController), Object(Illuminate\Routing\Route), 'pushnotificatio...') #14 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'RestPushNotific...', 'pushnotificatio...') #15 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}('257809') #16 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/Route.php(109): call_user_func_array(Object(Closure), Array) #17 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request)) #18 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #19 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #20 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request)) #21 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true) #22 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true) #23 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true) #24 /usr/share/nginx/html/cardiomeet/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true) #25 /usr/share/nginx/html/cardiomeet/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request)) #26 /usr/share/nginx/html/cardiomeet/public/index.php(49): Illuminate\Foundation\Application->run() #27 {main}

aymanfarhat commented 9 years ago

@piyushpatil027 Would be easier to figure out the problem if you share the chunk of code you're writing that is causing this error too. The exception alone is not enough. Also please format your code and output properly via markdown!.

piyushpatil027 commented 9 years ago

hi aymanfarhat,

PushNotification.php

$user = User::find($uid); $push_notification = $user->push_notifcation()->edge(); => this line gives error

User File

public function push_notifcation() { return $this->hasOne('PushNotifications', 'HAS_PUSHNOTIFICATION'); }

aymanfarhat commented 9 years ago

@piyushpatil027 You have to supply an instance of a node as an argument to the edge function call. This is a relationship between 2 nodes, $user is one node on one end, you need to pass an instance to the push notification node into edge() for that to work.

Example: $user->push_notifcation()->edge($myPushNotification);

piyushpatil027 commented 9 years ago

hi aymanfarhat,

Thanks for reply me. I used this ($user->push_notifcation()->edge($myPushNotification); ) but problem is still.

piyushpatil027 commented 9 years ago

hi aymanfarhat,

Thanks for helped me. I got solution.Actually problem is not in coding.Problem was function name is not declared properly. This function name doesnot allow (push_notifcation()) .I have chnage function name to (pushnotifcation()) and code is running. Thanks.

aymanfarhat commented 9 years ago

Welcome! :)