Use expand in actionMyfunction()

(Faizan Khattak) #1

I am developing REST API and I have an action Myfunction() and i wand to use expand
Here is my code

public function actionMyfunction() {
 $query = $this->model::find();
  return $query

My Model is

 public function fields() {
    return [

public function extraFields() {
     return ['status'];

This url not working for me


(Faizan Khattak) #2

@samdark will you help ?

(demonking) #3

Maybe i could help you. :slight_smile:

What do you get there? a 404 ?

Have you enabled prettyUrls?

Have you checked yii-debug ?

Here is explained, how you could use it :

From which Controller are you extending ?

yii/web/controller or yii/rest/controller?

(Faizan Khattak) #4

Extend from yii/rest/controller ActiveController

(demonking) #5

Can you answer my other questions? :slight_smile:

(Faizan Khattak) #6

yes i am using pretty url and debugging

(demonking) #7

does it work without params?


(Faizan Khattak) #8

with or without param its give one result. Not give status

(Eric) #9

if status is just a db field or property and not a model relation, then it won’t work because extraFields() is used to return data from a relation.