You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.2 KiB

<?php
namespace App;
use App\Models\Balance;
use App\Models\Orders;
use App\Models\Patient;
use App\Models\Recharge;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
/**
* App\Customer
*
* @property int $id
* @property string|null $name
* @property string|null $username
* @property string|null $sex
* @property string|null $mobile
* @property string $balance
* @property string|null $openid
* @property string|null $unionid
* @property string|null $password
* @property string|null $remember_token
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|Balance[] $balances
* @property-read int|null $balances_count
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
* @property-read int|null $notifications_count
* @property-read \Illuminate\Database\Eloquent\Collection|Patient[] $patients
* @property-read int|null $patients_count
* @method static \Illuminate\Database\Eloquent\Builder|Customer newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Customer newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Customer query()
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereBalance($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereMobile($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereOpenid($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer wherePassword($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereRememberToken($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereSex($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereUnionid($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereUsername($value)
* @mixin \Eloquent
*/
class Customer extends Authenticatable implements JWTSubject
{
use Notifiable;
const GUARD_NAME = "customer";
public function guardName()
{
return self::GUARD_NAME;
}
// Rest omitted for brevity
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'username', 'password', 'openid', 'balance', 'mobile','head_img_url'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'verified_at' => 'datetime',
];
public function patients()
{
return $this->hasMany(Patient::class, "customer_id");
}
public function balances()
{
return $this->hasMany(Balance::class, "customer_id");
}
public function oneBalance()
{
return $this->hasOne(Balance::class, "customer_id");
}
public function recharges()
{
return $this->hasMany(Recharge::class, "customer_id")->whereNotNull("paid_at");
}
public function orders()
{
return $this->hasMany(Orders::class, "customer_id");
}
}