👁 View: Coupon.php
Path: /home/thiqat5/tmphone.thiqatech.com/tm/app/Model/Coupon.php
Size: 569 B · Modified: 2021-11-17 23:00:14 · Perm: 0644 · Writable
<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Coupon extends Model
{
    protected $casts = [
        'min_purchase' => 'float',
        'max_discount' => 'float',
        'discount' => 'float',
        'status' => 'integer',
        'start_date' => 'date',
        'expire_date' => 'date',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    public function scopeActive($query)
    {
        return $query->where(['status' => 1])->where('start_date', '<=', now())->where('expire_date', '>', now());
    }
}