secure() ? "https" : "http"; if (!$this->avatar) { switch ($this->sex) { case "男": $this->avatar = "/images/male.png"; break; case "女": $this->avatar = "/images/female.png"; break; } } return $this->avatar ? $protocol . "://" . request()->getHost() . $this->avatar : $this->avatar; } public function getAgeAttribute() { if (date("Y-m-d",strtotime($this->birthday)) == $this->birthday) { return date("Y") - date("Y",strtotime($this->birthday)); } return ""; } public function scopeOfProject($query, $project_id) { return $query->whereIn("project_id", (array)$project_id); } public function project() { return $this->belongsTo(Project::class); } public function level() { return $this->belongsTo(ParamedicLevel::class, "paramedic_level_id", "id"); } public function levelInProject() { return $this->hasOneThrough(ProductParamedicLevel::class, ParamedicLevel::class,"id","paramedic_level_id","paramedic_level_id","id"); } public function orders() { return $this->hasMany(Orders::class); } public function ongoingOrders() { return $this->hasMany(Orders::class)->where("status", Orders::STATUS_ONGOING); } public function orderItems() { return $this->hasMany(OrderItems::class); } }