weizong song 5 years ago
parent 8073e6f1fe
commit ec91771d80

@ -7,7 +7,7 @@ use App\Scopes\AdminProjectScope;
class Paramedic extends SoftDeletesModel
{
protected $table = "paramedic";
public $appends = ["avatar_url"];
public $appends = ["avatar_url", "age"];
const STATUS_ACTIVE = 1;
const TEXT_ACTIVE = "正常";
@ -22,6 +22,13 @@ class Paramedic extends SoftDeletesModel
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);

Loading…
Cancel
Save