I'm trying to display the model data in the GridView column value, but it keep shows error: Call to a member function getUSD() on string.
I only want to display one data in that data cell. Can anyone know what's the problem?
Model code:
public static function getUSD(){
$getUSD = Rate::find()
->select('rate')
->where(['currency_name' => 'USD'])
->orderBy('rate_id DESC')
->one();
return $getUSD;
}
Code in the GirdView:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'summary' => '',
'columns' => [
[
'label' => 'USD',
'value' => function($model){
return $model->getUSD();
}
],
Expected output:
|USD|
| 4.102|