OrderDetailW.php 883 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class OrderDetailW extends Model
  5. {
  6. protected $connection = 'mysql_w';
  7. protected $table='order_detail';
  8. protected $fillable=['order_no','order_id','goods_id','user_id','store_id','price','cost_price','origin_price','num','account','size','type','style'];
  9. public function goods(){
  10. return $this->hasOne(StoreGoods::class,'id','goods_id');
  11. }
  12. public function order(){
  13. return $this->belongsTo(OrderW::class,'order_id','id');
  14. }
  15. public function getPriceAttribute($value){
  16. return round($value);
  17. }
  18. public function getCostPriceAttribute($value){
  19. return round($value);
  20. }
  21. public function getCostAccountAttribute($value){
  22. return round($value);
  23. }
  24. public function getAccountAttribute($value){
  25. return round($value);
  26. }
  27. }