Yii2 creating a custom function in the model using Gii model generator

Viewed 475

I am working on Yii2 using Gii to generate models. What I am trying to do is to customize my models such that all of them will have the following function

public static function getFoobarList() 
{
    $models = Foobar::find()->all();
    return ArrayHelper::map($models, 'id', 'foobar');
}

Where Foobar is the name of individual models.

Thank you in advance.

2 Answers
Related