131 lines
3.2 KiB
PHP
131 lines
3.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\User;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* Class UserAbo
|
|
*
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property int $payone_userid
|
|
* @property string $clearingtype
|
|
* @property string|null $wallettype
|
|
* @property int $amount
|
|
* @property string $currency
|
|
* @property bool $active
|
|
* @property int $status
|
|
* @property int $abo_interval
|
|
* @property Carbon|null $abo_date
|
|
* @property Carbon|null $next_abo_date
|
|
* @property Carbon|null $cancel_date
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property string|null $deleted_at
|
|
* @property Carbon|null $user_deleted_at
|
|
*
|
|
* @property User $user
|
|
* @property Collection|UserAboOrder[] $user_abo_orders
|
|
*
|
|
* @package App\Models
|
|
*/
|
|
class UserAbo extends Model
|
|
{
|
|
use SoftDeletes;
|
|
protected $table = 'user_abos';
|
|
|
|
protected $casts = [
|
|
'user_id' => 'int',
|
|
'shopping_user_id' => 'int',
|
|
'payone_userid' => 'int',
|
|
'amount' => 'int',
|
|
'active' => 'bool',
|
|
'status' => 'int',
|
|
'abo_interval' => 'int',
|
|
'start_date' => 'datetime',
|
|
'last_date' => 'datetime',
|
|
'next_date' => 'datetime',
|
|
'cancel_date' => 'datetime',
|
|
'count' => 'int',
|
|
'user_deleted_at' => 'datetime'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'shopping_user_id',
|
|
'is_for',
|
|
'payone_userid',
|
|
'clearingtype',
|
|
'wallettype',
|
|
'amount',
|
|
'currency',
|
|
'active',
|
|
'status',
|
|
'abo_interval',
|
|
'start_date',
|
|
'last_date',
|
|
'next_date',
|
|
'cancel_date',
|
|
'count',
|
|
'user_deleted_at'
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function shopping_user()
|
|
{
|
|
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
|
|
}
|
|
|
|
|
|
public function user_abo_orders()
|
|
{
|
|
return $this->hasMany(UserAboOrder::class);
|
|
}
|
|
|
|
public function setStartDateAttribute( $value ) {
|
|
$this->attributes['start_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
|
}
|
|
public function getStartDateAttribute()
|
|
{
|
|
return $this->attributes['start_date'] ? Carbon::parse($this->attributes['start_date'])->format(\Util::formatDateDB()) : '';
|
|
}
|
|
|
|
public function setLastDateAttribute( $value ) {
|
|
$this->attributes['last_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
|
}
|
|
public function getLastDateAttribute()
|
|
{
|
|
return $this->attributes['last_date'] ? Carbon::parse($this->attributes['last_date'])->format(\Util::formatDateDB()) : '';
|
|
}
|
|
|
|
public function setNextDateAttribute( $value ) {
|
|
$this->attributes['next_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
|
}
|
|
public function getNextDateAttribute()
|
|
{
|
|
return $this->attributes['next_date'] ? Carbon::parse($this->attributes['next_date'])->format(\Util::formatDateDB()) : '';
|
|
}
|
|
|
|
public function setCancelDateAttribute( $value ) {
|
|
$this->attributes['cancel_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
|
}
|
|
public function getCancelDateAttribute()
|
|
{
|
|
return $this->attributes['cancel_date'] ? Carbon::parse($this->attributes['cancel_date'])->format(\Util::formatDateDB()) : '';
|
|
}
|
|
|
|
|
|
}
|