2017-01-10 18 views

回答

3

及其對添加到模型的accesor較晚,但以供參考:

如果僅用於後端列表,則可以輕鬆創建新的列類型貨幣並使用它。 see documentation

在你的情況,你將以下內容添加到您的Plugin.php:

public function registerListColumnTypes() 
{ 
    return [ 
    'currency' => function($value) { 
         return money_format($value, 2); 
         } 
    ]; 
} 

現在你可以使用在每一個coulmns.yaml在你的插件:

columns 
    title: 
    label: Title 
    type: text 
    amount: 
    type: currency 
    label: Amount