1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Models/BillingSubscription.php
Benjamin Beganović 81f5808bf6 - Use user from $billing_subscription to create client
- Disable generating the cache for temporary state
- Generate the blank invoice based on the product
2021-03-17 12:06:58 +01:00

77 lines
1.9 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Models;
use App\Services\BillingSubscription\BillingSubscriptionService;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class BillingSubscription extends BaseModel
{
use HasFactory, SoftDeletes;
protected $fillable = [
'user_id',
'product_id',
'company_id',
'product_id',
'is_recurring',
'frequency_id',
'auto_bill',
'promo_code',
'promo_discount',
'is_amount_discount',
'allow_cancellation',
'per_set_enabled',
'min_seats_limit',
'max_seats_limit',
'trial_enabled',
'trial_duration',
'allow_query_overrides',
'allow_plan_changes',
'plan_map',
'refund_period',
'webhook_configuration',
'currency_id',
];
protected $casts = [
'is_deleted' => 'boolean',
'plan_map' => 'object',
'webhook_configuration' => 'object',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
];
public function service()
{
return new BillingSubscriptionService($this);
}
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Company::class);
}
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function product(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Product::class);
}
}