12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Modules\Product\Models;
- use Illuminate\Database\Eloquent\Model;
- class Product extends Model
- {
- protected $table = 'products';
- protected $fillable = ['price', 'type', 'given', 'is_default', 'is_enabled', 'sequence', 'switch_to','qapp_charge_template_id'];
- public static function getChargeProduct($template_type)
- {
- return self::whereIn('products.type', ['TICKET_RECHARGE', 'YEAR_ORDER',"MONTH_ORDER", "",'NEW_USER'])
- ->where('is_enabled', 1)
- ->where('template_type', $template_type)
- ->select(
- 'products.id',
- 'products.price',
- 'products.type',
- 'products.given',
- 'products.is_default',
- 'products.sequence',
- 'products.switch_to'
- )
- ->orderBy('sequence')->get();
- }
- /**
- * 获取id下对应的充值和赠送额
- * @param $product_id
- * @return mixed
- */
- public static function getProductGivenAmount($product_id)
- {
- return self::where('id', $product_id)->select('given', 'price')->first();
- }
- static function detail($id)
- {
- return self::find($id);
- }
- public static function getProductsByIds($ids)
- {
- $result = self::whereIn('id', $ids)->get();
- return $result ? $result->toArray() : [];
- }
- }
|