123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Models\Product;
- use Illuminate\Database\Eloquent\Model;
- class Product extends Model
- {
- protected $table = 'products';
- protected $fillable = ['price', 'type','name','name_desc','price_desc','angle_sign_text','template_id', 'given', 'is_default', 'is_enabled', 'sequence','template_type'];
- public static function getChargeProduct($template_type)
- {
- return self::whereIn('products.type', ['WEEK', 'MONTH','QUARTER','HALF_YEAR','YEAR', 'RECHARGE'])
- ->where('is_enabled', 1)
- ->where('template_type', $template_type)
- ->select(
- 'products.id',
- 'products.price',
- 'products.price_desc',
- 'products.name',
- 'products.name_desc',
- 'products.type',
- 'products.given',
- 'products.is_default',
- 'products.sequence',
- 'products.angle_sign_text'
- )
- ->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);
- }
- static function getProductsByIds($ids)
- {
- return self::whereIn('id', $ids)->get();
- }
- }
|