Get data by URL in rest api yii2

0

I currently get data from my service in the following way:

link

And the service shows me all the users but only their nopmbres as specific in the route.

Now I would like you to show me a specific data. eg:

link and it will only show me the name of "Jorge"

My service I raise it in the following way The controller:

class AmigosController extends ActiveController {    public $ modelClass = 'backend \ models \ Friends'; } ...

The model:

class Friends extends \ yii \ db \ ActiveRecord {     / **      * @inheritdoc      * /     public static function tableName ()     {         return 'friends';     }

/**
 * @inheritdoc
 */
public function rules()
{
    return [
        [['idUsuarioAmigo', 'idUsuarioAgregadoAmigo', 'fechaAltaAmigo', 'estatusAmigo'], 'required'],
        [['idUsuarioAmigo', 'idUsuarioAgregadoAmigo'], 'integer'],
        [['fechaAltaAmigo'], 'safe'],
        [['estatusAmigo'], 'string', 'max' => 20],
        [['idUsuarioAgregadoAmigo'], 'exist', 'skipOnError' => true, 'targetClass' => Usuarios::className(), 'targetAttribute' => ['idUsuarioAgregadoAmigo' => 'idUsuario']],
        [['idUsuarioAmigo'], 'exist', 'skipOnError' => true, 'targetClass' => Usuarios::className(), 'targetAttribute' => ['idUsuarioAmigo' => 'idUsuario']],
    ];
}

/**
 * @inheritdoc
 */
public function attributeLabels()
{
    return [
        'idAmigo' => Yii::t('app', 'Id Amigo'),
        'idUsuarioAmigo' => Yii::t('app', 'Id Usuario Amigo'),
        'idUsuarioAgregadoAmigo' => Yii::t('app', 'Id Usuario Agregado Amigo'),
        'fechaAltaAmigo' => Yii::t('app', 'Fecha Alta Amigo'),
        'estatusAmigo' => Yii::t('app', 'Estatus Amigo'),
    ];
}
    
asked by Jasi Enriquez 06.03.2017 в 22:55
source

1 answer

0

Basically what you want to do is a "search"

link

and in the FriendsController index you can write the logic. Remember that the name you get with:

Yii::$app->getRequest()->getQueryParam('nombre')

in this case

    
answered by 06.03.2017 / 23:25
source