Product.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Modules\Product\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Product extends Model
  5. {
  6. protected $table = 'products';
  7. protected $fillable = ['price', 'type', 'given', 'is_default', 'is_enabled', 'sequence'];
  8. public static function getChargeProduct($template_type)
  9. {
  10. return self::whereIn('products.type', ['TICKET_RECHARGE', 'YEAR_ORDER','NEW_USER'])
  11. ->where('is_enabled', 1)
  12. ->where('template_type', $template_type)
  13. ->select(
  14. 'products.id',
  15. 'products.price',
  16. 'products.type',
  17. 'products.given',
  18. 'products.is_default',
  19. 'products.sequence'
  20. )
  21. ->orderBy('sequence')->get();
  22. }
  23. /**
  24. * 获取id下对应的充值和赠送额
  25. * @param $product_id
  26. * @return mixed
  27. */
  28. public static function getProductGivenAmount($product_id)
  29. {
  30. return self::where('id', $product_id)->select('given','price')->first();
  31. }
  32. static function detail($id)
  33. {
  34. return self::find($id);
  35. }
  36. }