'json', ]; protected $dates = [ 'start_at', 'stop_at', 'charge_at', // The date the charge applies - since it can be different to created_at ]; public const sweep = [ // 0 => 'Daily', // 1 => 'Weekly', // 2 => 'Monthly', // 3 => 'Quarterly', // 4 => 'Semi-Annually', // 5 => 'Annually', 6 => 'Service Rebill', ]; /* RELATIONS */ public function account() { return $this->belongsTo(Account::class); } public function product() { return $this->belongsTo(Product::class); } public function service() { return $this->belongsTo(Service::class); } /* SCOPES */ public function scopeUnprocessed($query) { return $query ->where('active',TRUE) ->whereNotNull('charge_at') ->whereNotNull('type') ->where(function($q) { return $q->where('processed',FALSE) ->orWhereNull('processed'); }); } /* ATTRIBUTES */ public function getNameAttribute() { return sprintf('%s %s',$this->description,$this->getAttribute('attributes') ? join('|',unserialize($this->getAttribute('attributes'))) : ''); } public function getTypeNameAttribute(): string { return Arr::get(InvoiceItem::type,$this->type); } }