Yii2 Restful API : display the data from database into JSON format with specific condition

hello guys. I working on Yii2 RESTFUL API right now. Basically, I already known about RESTFUL API with easy step and I follow from this /doc-2.0/guide-rest-quick-start.html. Besides that, I also read about REST API from this vinaysahni.cm/best-practices-for-a-pragmatic-restful-api.

I already create a simple project and try run at browser( localhost/KDMA/web/index.php/volunteers/1). the data will display like this:

{

"volunteer_id": "1",

"state_id":"12",

"nama": "Bentong",

}

that result is display the data from volunteer_id = 1. And what I want to do right now is, I want to display the data from state_id with volunteer information. This is my structure database :

TABLE volunteer(

volunteer_id int(11) NOT NULL auto_increment,

state_id int(11) null

nama varchar(200) null

address varchar(200) null

TABLE state(

state_id int(11) NOT NULL auto_increment,

state varchar(225) null

If in SQL code we can write like this SELECT * FROM volunteer where state_id = 1. But, how about in RESTFUL API ?

$modaldata = volunteer()::find()->where([‘stateid’ => 1])->all();