form stuff done
This commit is contained in:
@ -7,6 +7,16 @@ use App\Models\Model;
|
||||
class Recurring extends Model
|
||||
{
|
||||
|
||||
protected $table = 'recurrings';
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'recurrable_id', 'recurrable_type', 'frequency', 'interval', 'started_at', 'count'];
|
||||
|
||||
|
||||
/**
|
||||
* Get all of the owning recurrable models.
|
||||
*/
|
||||
|
@ -58,26 +58,21 @@ class Bill extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cloneable_relations = ['items', 'totals'];
|
||||
protected $cloneable_relations = ['items', 'recurring', 'totals'];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Category');
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Expense\Vendor');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function status()
|
||||
public function histories()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Expense\BillStatus', 'bill_status_code', 'code');
|
||||
return $this->hasMany('App\Models\Expense\BillHistory');
|
||||
}
|
||||
|
||||
public function items()
|
||||
@ -85,19 +80,29 @@ class Bill extends Model
|
||||
return $this->hasMany('App\Models\Expense\BillItem');
|
||||
}
|
||||
|
||||
public function totals()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillTotal');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillPayment');
|
||||
}
|
||||
|
||||
public function histories()
|
||||
public function recurring()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillHistory');
|
||||
return $this->morphOne('App\Models\Common\Recurring', 'recurrable');
|
||||
}
|
||||
|
||||
public function status()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Expense\BillStatus', 'bill_status_code', 'code');
|
||||
}
|
||||
|
||||
public function totals()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense\BillTotal');
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Expense\Vendor');
|
||||
}
|
||||
|
||||
public function scopeDue($query, $date)
|
||||
|
@ -44,24 +44,31 @@ class Payment extends Model
|
||||
'description' ,
|
||||
];
|
||||
|
||||
/**
|
||||
* Clonable relationships.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cloneable_relations = ['recurring'];
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Banking\Account');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Category');
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Expense\Vendor');
|
||||
return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function recurring()
|
||||
{
|
||||
return $this->morphOne('App\Models\Common\Recurring', 'recurrable');
|
||||
}
|
||||
|
||||
public function transfers()
|
||||
@ -69,6 +76,11 @@ class Payment extends Model
|
||||
return $this->hasMany('App\Models\Banking\Transfer');
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Expense\Vendor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get only transfers.
|
||||
*
|
||||
|
@ -59,7 +59,7 @@ class Invoice extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cloneable_relations = ['items', 'totals'];
|
||||
protected $cloneable_relations = ['items', 'recurring', 'totals'];
|
||||
|
||||
public function category()
|
||||
{
|
||||
@ -91,9 +91,9 @@ class Invoice extends Model
|
||||
return $this->hasMany('App\Models\Income\InvoicePayment');
|
||||
}
|
||||
|
||||
public function recurrings()
|
||||
public function recurring()
|
||||
{
|
||||
return $this->morphMany('App\Models\Common\Recurring', 'recurrable');
|
||||
return $this->morphOne('App\Models\Common\Recurring', 'recurrable');
|
||||
}
|
||||
|
||||
public function status()
|
||||
|
@ -45,6 +45,13 @@ class Revenue extends Model
|
||||
'notes' => 2,
|
||||
];
|
||||
|
||||
/**
|
||||
* Clonable relationships.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cloneable_relations = ['recurring'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Auth\User', 'customer_id', 'id');
|
||||
@ -70,6 +77,11 @@ class Revenue extends Model
|
||||
return $this->belongsTo('App\Models\Income\Customer');
|
||||
}
|
||||
|
||||
public function recurring()
|
||||
{
|
||||
return $this->morphOne('App\Models\Common\Recurring', 'recurrable');
|
||||
}
|
||||
|
||||
public function transfers()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transfer');
|
||||
|
Reference in New Issue
Block a user