akaunting 3.0 (the last dance)
This commit is contained in:
@ -4,11 +4,16 @@ namespace App\Models\Common;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Recurring as RecurringTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Recurring extends Model
|
||||
{
|
||||
use RecurringTrait;
|
||||
|
||||
public const ACTIVE_STATUS = 'active';
|
||||
public const END_STATUS = 'ended';
|
||||
public const COMPLETE_STATUS = 'completed';
|
||||
|
||||
protected $table = 'recurring';
|
||||
|
||||
/**
|
||||
@ -16,7 +21,30 @@ class Recurring extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'recurable_id', 'recurable_type', 'frequency', 'interval', 'started_at', 'count', 'created_from', 'created_by'];
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'recurable_id',
|
||||
'recurable_type',
|
||||
'frequency',
|
||||
'interval',
|
||||
'started_at',
|
||||
'status',
|
||||
'limit_by',
|
||||
'limit_count',
|
||||
'limit_date',
|
||||
'auto_send',
|
||||
'created_from',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'auto_send' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all of the owning recurable models.
|
||||
@ -25,4 +53,19 @@ class Recurring extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where($this->qualifyColumn('status'), '=', static::ACTIVE_STATUS);
|
||||
}
|
||||
|
||||
public function scopeEnded(Builder $query): Builder
|
||||
{
|
||||
return $query->where($this->qualifyColumn('status'), '=', static::END_STATUS);
|
||||
}
|
||||
|
||||
public function scopeCompleted(Builder $query): Builder
|
||||
{
|
||||
return $query->where($this->qualifyColumn('status'), '=', static::COMPLETE_STATUS);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user