datitisev
Error 500 when I try to react:
Debug code:
POST https://mysite.com/api/posts/158
{
"errors": [
{
"status": "500",
"code": "unknown",
"detail": "BadMethodCallException: Call to undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::attach() in /home/mysite/vendor/illuminate/support/Traits/ForwardsCalls.php:50\nStack trace:\n#0 /home/mysite/vendor/illuminate/support/Traits/ForwardsCalls.php(36): Illuminate\\Database\\Eloquent\\Relations\\Relation::throwBadMethodCallException('attach')\n#1 /home/mysite/vendor/illuminate/database/Eloquent/Relations/Relation.php(386): Illuminate\\Database\\Eloquent\\Relations\\Relation->forwardCallTo(Object(Illuminate\\Database\\Eloquent\\Builder), 'attach', Array)\n#2 /home/mysite/vendor/fof/reactions/src/Listener/SaveReactionsToDatabase.php(138): Illuminate\\Database\\Eloquent\\Relations\\Relation->__call('attach', Array)\n#3 [internal function]: FoF\\Reactions\\Listener\\SaveReactionsToDatabase->handle(Object(Flarum\\Post\\Event\\Saving))\n#4 /home/mysite/vendor/illuminate/events/Dispatcher.php(379): call_user_func_array(Array, Array)\n#5 /home/mysite/vendor/illuminate/events/Dispatcher.php(209): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Flarum\\\\Post\\\\Eve...', Array)\n#6 /home/mysite/vendor/flarum/core/src/Post/Command/EditPostHandler.php(81): Illuminate\\Events\\Dispatcher->dispatch('Flarum\\\\Post\\\\Eve...')\n#7 /home/mysite/vendor/illuminate/bus/Dispatcher.php(90): Flarum\\Post\\Command\\EditPostHandler->handle(Object(Flarum\\Post\\Command\\EditPost))\n#8 /home/mysite/vendor/illuminate/pipeline/Pipeline.php(128): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(Flarum\\Post\\Command\\EditPost))\n#9 /home/mysite/vendor/illuminate/pipeline/Pipeline.php(104): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Flarum\\Post\\Command\\EditPost))\n#10 /home/mysite/vendor/illuminate/bus/Dispatcher.php(98): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))\n#11 /home/mysite/vendor/illuminate/bus/Dispatcher.php(76): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(Flarum\\Post\\Command\\EditPost))\n#12 /home/mysite/vendor/flarum/core/src/Api/Controller/UpdatePostController.php(57): Illuminate\\Bus\\Dispatcher->dispatch(Object(Flarum\\Post\\Command\\EditPost))\n#13 /home/mysite/vendor/flarum/core/src/Api/Controller/AbstractSerializeController.php(96): Flarum\\Api\\Controller\\UpdatePostController->data(Object(Laminas\\Diactoros\\ServerRequest), Object(Tobscure\\JsonApi\\Document))\n#14 /home/mysite/vendor/flarum/core/src/Http/RouteHandlerFactory.php(38): Flarum\\Api\\Controller\\AbstractSerializeController->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#15 /home/mysite/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php(65): Flarum\\Http\\RouteHandlerFactory->Flarum\\Http\\{closure}(Object(Laminas\\Diactoros\\ServerRequest), Array)\n#16 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\DispatchRoute->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Closure))\n#17 /home/mysite/vendor/flarum/core/src/Http/Middleware/SetLocale.php(50): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#18 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\SetLocale->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#19 /home/mysite/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(45): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#20 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\CheckCsrfToken->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#21 /home/mysite/vendor/flarum/core/src/Http/Middleware/AuthenticateWithHeader.php(55): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#22 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\AuthenticateWithHeader->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#23 /home/mysite/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(32): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#24 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\AuthenticateWithSession->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#25 /home/mysite/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(51): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#26 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\RememberFromCookie->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#27 /home/mysite/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#28 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\StartSession->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#29 /home/mysite/vendor/flarum/core/src/Api/Middleware/FakeHttpMethods.php(29): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#30 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Api\\Middleware\\FakeHttpMethods->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#31 /home/mysite/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#32 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\ParseJsonBody->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#33 /home/mysite/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#34 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\HandleErrors->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#35 /home/mysite/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(84): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#36 /home/mysite/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\\Stratigility\\MiddlewarePipe->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#37 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\\RequestHandler->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#38 /home/mysite/vendor/middlewares/base-path-router/src/BasePathRouter.php(97): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#39 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\\BasePathRouter->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#40 /home/mysite/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(42): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#41 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Laminas\\Stratigility\\Middleware\\OriginalMessages->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#42 /home/mysite/vendor/middlewares/base-path/src/BasePath.php(53): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#43 /home/mysite/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\\BasePath->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#44 /home/mysite/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(84): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#45 /home/mysite/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(73): Laminas\\Stratigility\\MiddlewarePipe->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\EmptyPipelineHandler))\n#46 /home/mysite/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(96): Laminas\\Stratigility\\MiddlewarePipe->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#47 /home/mysite/vendor/flarum/core/src/Http/Server.php(42): Laminas\\HttpHandlerRunner\\RequestHandlerRunner->run()\n#48 /home/mysite/index.php(26): Flarum\\Http\\Server->listen()\n#49 {main}"
}
]
}