Currently I get data from my service in the following way:
http://localhost/users?fields=name
And the service shows me all the users but only their names as specified in the route.
Now I would like you to show me a specific piece of information. e.g.:
http://localhost/users?fields=name=Jorge and it will show me only the name of "jorge"
My service is raised as follows The controller:
class FriendsController 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'),
];
}