100 lines
3.1 KiB
PHP
100 lines
3.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class UserPaymentOption
|
|
*
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property int $payment_option_id
|
|
* @property int|null $coupon_id
|
|
* @property string $status
|
|
* @property Carbon|null $valid_until_date
|
|
* @property Carbon|null $next_due_date
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property Coupon|null $coupon
|
|
* @property PaymentOption $payment_option
|
|
* @property SfGuardUser $sf_guard_user
|
|
* @property Collection|UserPayment[] $user_payments
|
|
* @property Collection|Company[] $companies
|
|
* @property UserPaymentOptionReference $user_payment_option_reference
|
|
* @package App\Models
|
|
* @property-read int|null $companies_count
|
|
* @property-read int|null $user_payments_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereCouponId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereNextDueDate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption wherePaymentOptionId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereUserId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPaymentOption whereValidUntilDate($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class UserPaymentOption extends Model
|
|
{
|
|
protected $table = 'user_payment_option';
|
|
|
|
protected $casts = [
|
|
'user_id' => 'int',
|
|
'payment_option_id' => 'int',
|
|
'coupon_id' => 'int',
|
|
'valid_until_date' => 'datetime',
|
|
'next_due_date' => 'datetime'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'payment_option_id',
|
|
'coupon_id',
|
|
'status',
|
|
'valid_until_date',
|
|
'next_due_date'
|
|
];
|
|
|
|
public function coupon()
|
|
{
|
|
return $this->belongsTo(Coupon::class);
|
|
}
|
|
|
|
public function payment_option()
|
|
{
|
|
return $this->belongsTo(PaymentOption::class);
|
|
}
|
|
|
|
public function sf_guard_user()
|
|
{
|
|
return $this->belongsTo(SfGuardUser::class, 'user_id');
|
|
}
|
|
|
|
public function user_payments()
|
|
{
|
|
return $this->hasMany(UserPayment::class);
|
|
}
|
|
|
|
public function companies()
|
|
{
|
|
return $this->belongsToMany(Company::class, 'user_payment_option_company', 'payment_option_id')
|
|
->withPivot('ip_address', 'is_active')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function user_payment_option_reference()
|
|
{
|
|
return $this->hasOne(UserPaymentOptionReference::class, 'parent_user_payment_option_id');
|
|
}
|
|
}
|