[英]laravel accessor very slow
我有一個叫做journal_entries
的表,在這個表里面我有兩個列
price
price_t
現在,如果此人是管理員,我希望他看到價格列,但如果此人不是管理員,我希望他將 price_t 視為價格,這是我的訪問器代碼
public function getTotalNetPriceAttribute()
{
if(!Gate::allows('info'))
{
if(isset($this->attributes['total_net_price_t']))
{
if($this->attributes['total_net_price_t'] == null)
return $this->attributes['total_net_price'];
else
return $this->attributes['total_net_price_t'];
}
if(isset($this->attributes['total_net_price']))
return $this->attributes['total_net_price'];
}
else
{
if(isset($this->attributes['total_net_price']))
return $this->attributes['total_net_price'];
}
}
現在,如果該人是管理員,則代碼將正常時間(例如 1 到 2 分鍾)作為計算其正常時間的真正平衡,但是如果用戶現在管理其時間很長很長時間,那么訪問者是否有任何方法可以加快速度謝謝..
問題出在門文件上,現在它工作得很好,謝謝大家
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.