Comments (11)
Hi faidoc!
Hum, are you sure you have mongoDB installed?
if not: http://www.mongodb.org/downloads
Or, maybe try removing these lines at the beginning of you model classes:
use Jenssegers\Mongodb\Model as Eloquent;
another ideas:
http://docs.mongodb.org/ecosystem/drivers/php/
Please, let me know how you fixed it when you do!
from laravel-restful-api-starter.
Yep, I commented those lines and it works. Now the only problem I see is with the /users/{users}/show route
I'm doing for example after registering the first user:
First I log in with the user in /users/auth
Then, try this other: /users/0/show but I end up with the error
{"error":{"code":500,"message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.id' in 'where clause' (SQL: select * from
userswhere
users.
deleted_atis null and
users.
id= 0 limit 1)","file":"\/home\/vagrant\/Code\/prueba.com\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Connection.php","line":625}}
The error says it can not find the column users.id and the correct name as I can see it on the database is _id. Where can I correct that column name? I can't find it on the models...
Thanks
from laravel-restful-api-starter.
Hum.. i think laravel eloquent use by default the id as primary key in the db. I think there is a way to force using it with _id. Probably specifying a parameter in the model. You may have some doc about it on the official doc.
I mainly tested the api with mongodb so my code may have a few glitches like this.. sorry :s
from laravel-restful-api-starter.
Yes, thanks, I searched for that and found that I can do:
protected $primaryKey = '_id';
on the Users model.
Now... I promise... last question xD... I get that there's no token for /users/0/show when theres a user with _id 0 and a token where the user_id is 0
What do you think is wrong now?
Thank you and sorry xD
from laravel-restful-api-starter.
No worries.
Usually with mysql, primary keys start at index 1.
Have a look in your db.
Thanks
from laravel-restful-api-starter.
Ok I saw that the migration didn't put the _id autoincremental so I made some changes because it was failing when creating a second user. Changed it to autoincremental and put the first user as 1.
Now I know there's the token for the user when I log in. I post with postman and get status 202 accepted.
But with /users/1/show it keeps saying there's no token.
To make sure I'm doing it right in postman, I do this with the basic Auth tab, where I put the email and password I put when registering the user, this gives me the authorization header that I put like:
Authorization Basic ZmFpZG9jQGdtYWlsLmNvbTp0aWNrZXQ=
And execute the GET in /users/1/show
I get status 401 Unauthorized... -.-
from laravel-restful-api-starter.
Finally got it -.-
The request had to be with a URL parameter with the token received when you log in right?
For example:
http://test.com/v1/users/1/show?token=N2tFeUwwZWE5OGhRQkJTTFFuZklaRVZ5eFBWVEFSZUhtaUh0WlNWZz0=
That way it shows the session.
Thanks for your help trying to figure it out all these things
from laravel-restful-api-starter.
Hello, this looks very promising, looking for a solution like this for hours now!
Could you have time to make a new version just for mysql?
from laravel-restful-api-starter.
Thx,
I'll try to find a moment this week-end..
from laravel-restful-api-starter.
Merlosy,
I am working on a solution that requires data access control based on roles.
Would you be interested in adding starter code for that functionality to the project?
from laravel-restful-api-starter.
Hi kwab,
why not.. Can you open a new issue for that?
I'd rather keep things organized as this issue will be solved soon.
Do you already have some code about it?
Thx
from laravel-restful-api-starter.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-restful-api-starter.