![]() |
|
Laravel JsonApi - Printable Version +- -TWC| Forum (https://board.twcclan.org) +-- Forum: Offtopic (https://board.twcclan.org/forum-28.html) +--- Forum: Hydepark (https://board.twcclan.org/forum-32.html) +---- Forum: Technology (https://board.twcclan.org/forum-151.html) +---- Thread: Laravel JsonApi (/thread-8722.html) |
Laravel JsonApi - LePresident - 09-08-2019 Hi everybody. I'm currently in an dev internship, and I have to create APIs with php/Laravel/JsonApi. I use [URL="https://jsonapi.org/"]{json:api}[/URL] and [URL="https://laravel-json-api.readthedocs.io/en/latest/"]https://laravel-json-api.readthedocs.io/en/latest/[/URL] No problem with php and Laravel, but I'm stuck with JsonApi, with some id name issue ! Problem is, I'm the first in the enterprise to use JsonApi, so none of my colleagues can help me. I use the [URL="https://jsonapi.org/"]{json:api}[/URL] official manual everyday, and I've tried everything described but can't find a functional solution in-there. I've asked on Stack Overflow, no response... Maybe someone knows how to use Laravel and JsonApi, or knows someone who could help... RE: Laravel JsonApi - Ligustah - 11-08-2019 Never used either of these. Can you link the StackOverflow question and/or describe your problem? RE: Laravel JsonApi - LePresident - 14-08-2019 Hi. Sorry for being so long, I was quite busy. I found some fixes to my some of my troubles. But I still have a big issue. I asked on StackOverflow some questions, like How to use Laravel JSONAPI, which I managed to fix. Now, basically, I can use the Laravel {json:api} framework, connect to the database, and retrieve any list of records I need (i.e /myurl/myobjects). But if I try to access a existing record (i.e. /myurl/myobjects/1), I get a 404 error, the id 1 is not found. Yep, cause we use ID and not id in the database. So, all I need is to change id to ID. I searched in the manual, on the net, everything... Found some stuff like declaring Code: $privateKey = 'ID';RE: Laravel JsonApi - LePresident - 19-08-2019 OK, I went back to my internship after a week of vacation, and found where my error was. I used artisan to generate an adapter, and I thought it was good, but nope. artisan generates an empty find() method in the adapter, so ofc, this won't work. I digged into the Laravel-json-api github, and found how to define the find() method : Code: public function find($resourceId)
{
return $this->findQuery($resourceId)->first();
}Now, we're talking
RE: Laravel JsonApi - Ligustah - 21-08-2019 Glad to hear you got it working. Sorry I didn't get back earlier, we're in release mode at work so I was busy and forgot. RE: Laravel JsonApi - LePresident - 21-08-2019 Yeah, that was a lot of stress, but, hey, that's part of the game ![]() I hope you enjoy your work as much as I do
|