Membership
This commit is contained in:
parent
37cb2b06c7
commit
21abafb8db
51 changed files with 1549 additions and 493 deletions
35
app/User.php
35
app/User.php
|
|
@ -86,6 +86,19 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read \App\User|null $user_sponsor
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereMLevel($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereMSponsor($value)
|
||||
* @property string|null $release_account
|
||||
* @property int|null $payment_order_id
|
||||
* @property int|null $abo_options
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\File[] $files
|
||||
* @property-read int|null $files_count
|
||||
* @property-read \App\Models\Product|null $payment_order
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
|
||||
* @property-read int|null $shopping_orders_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereAboOptions($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereReleaseAccount($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserHistory[] $user_histories
|
||||
* @property-read int|null $user_histories_count
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
|
@ -96,7 +109,6 @@ class User extends Authenticatable
|
|||
|
||||
protected $table = 'users';
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
|
@ -126,23 +138,24 @@ class User extends Authenticatable
|
|||
|
||||
public function user_sponsor(){
|
||||
return $this->belongsTo('App\User', 'm_sponsor');
|
||||
|
||||
}
|
||||
|
||||
public function payment_order(){
|
||||
public function payment_order_product(){
|
||||
return $this->belongsTo('App\Models\Product', 'payment_order_id');
|
||||
}
|
||||
|
||||
public function files(){
|
||||
return $this->hasMany('App\Models\File', 'user_id', '');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function shopping_orders(){
|
||||
return $this->hasMany('App\Models\ShoppingOrder', 'auth_user_id', '');
|
||||
|
||||
}
|
||||
|
||||
public function user_histories(){
|
||||
return $this->hasMany('App\Models\UserHistory', 'user_id', '');
|
||||
}
|
||||
|
||||
public function shop()
|
||||
{
|
||||
|
|
@ -150,7 +163,6 @@ class User extends Authenticatable
|
|||
}
|
||||
|
||||
|
||||
|
||||
public function user_update_email()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id');
|
||||
|
|
@ -227,6 +239,17 @@ class User extends Authenticatable
|
|||
return $this->payment_shop ? Carbon::parse($this->payment_shop)->gt(Carbon::now()) : false;
|
||||
}
|
||||
|
||||
public function isRenewalAccount()
|
||||
{
|
||||
if ($this->payment_account) {
|
||||
return Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->lt(Carbon::now());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function nextRenewalAccount(){
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false ;
|
||||
}
|
||||
|
||||
|
||||
public function daysActiveAccount(){
|
||||
return Carbon::now()->diffInDays(Carbon::parse($this->payment_account), false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue