In yii2 I have to use SQL with user-defined dynamic alias.
So as it's dynamic so it's not possible to add as public property in the model.
So following code is not working with following SQL:
SELECT `item_id` AS `Item Id`,
`on_hand` AS `On Hand`,
`initial_on_hand` AS `Amount Produced`,
`best_by_date` AS `Best By`,
`item_name` AS `Item Name`
FROM `stock`
here is yii2 code:
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
So whats the possible solution using which I can use yii2 grid with pagination and controls?
use this solution
instead of doing this you can just simply create a method called attributeLabels() inside of your model stock if your purpose is getting labels .