I am creating a RESTful web service using Laravel and a one-page front-panel application with Angluarjs. Now where should I place Angularjs files? Do I have to put them in the Laravel installation shared folder or do I have to keep them completely separate, as I will send calls to resources in the web service and return JSON data, and therefore there is no need for them to be in the same place. What is the standard or best practice?
Now, for the second part. How do I manage my routes and resources in Laravel if I create a simple Todo app. I'm really confused here, and it's a little hard for me to explain, but stay with me for a moment. For example, I have a user resource y / users, and I can get all users by issuing a GET request to / users or creating new users by sending a POST request to / users. Similarly, I can execute a GET request from / users / 1 and get the first user, etc. With other request verbs. Now I have another resource called tasks. How to implement this resource? Should I implement it as a say / users / {user_id} / tasks nested resource. When I issue a GET request in / users / 1 / tasks, it will retrieve all the tasks for the first user. But now it's getting complicatedbecause if you issue a GET request in / users / 10 / tasks / 1, it must complete the first task for the 10th user. But then the implementation of such logic becomes very difficult, since I have to look for the first task of the 10th user.
I thought about this, setting only the GET route to / users / {user_id} / tasks, which will obviously return all tasks for the specified user. And then I would create a completely different resource / task to handle all the other request verbs. Am I doing it right?
And also, if I use NoSQL DB, for example MongoDB, in which case the data will be stored in such a way that / users / {user_id} / tasks / {task_id} will not be difficult to implement, since each user's tasks will be in their own JSON object .
I think in the right direction? I am new and I don’t know exactly what is the standard way to solve such problems with database architecture? What are the best practices?
Rohan source
share