123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?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'];
- public static function getChargeProduct($template_type)
- {
- return self::whereIn('products.type', ['TICKET_RECHARGE', 'YEAR_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'
- )
- ->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);
- }
- }
|