S
S
Stanislav Tarasenko2015-08-31 12:27:07
MySQL
Stanislav Tarasenko, 2015-08-31 12:27:07

How to build a RESTful API to work with data in related tables?

Can you please tell me how to build work with data from different tables?
Reading is clear, there is nothing complicated here. But what about the record, i.e. POST, PUT?
For example, content with multiple languages.
The question is entirely related to Yii2.
I have two assumptions:
1. Create an action in which to parse the data that came in and shuffle it into different models.
2. Create api requests for each model (table).
Please advise.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Pronin, 2015-08-31
@STarasenko

Good afternoon, Stanislav Tarasenko Rest means manipulations with entities. If your content (as I understand it, for example, an article) contains several languages, then this entity is one, therefore, it should be edited through one API point

L
LAV45, 2015-09-10
@LAV45

For example, content with multiple languages.

You can use this Behavior https://github.com/LAV45/yii2-translated-behavior
You just work with the main Post model and don't think about what table to write to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question