Nurse.php 810 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-10-4
  6. * Time: 下午4:35
  7. */
  8. namespace App\Models;
  9. class Nurse extends BaseModel
  10. {
  11. protected $appends = ['today'];
  12. const NURSEFREE = 1,NURSEFEE = 2;
  13. public static $_type = [
  14. self::NURSEFREE=>'免费',
  15. self::NURSEFEE=>'自费'
  16. ];
  17. public static function getNursetype ()
  18. {
  19. return self::$_type;
  20. }
  21. public function getTodayAttribute()
  22. {
  23. return OrderNurse::where(['nurse_id' => $this->id, 'created_at' => ['>', date('Y-m-d 00:00:00', time())]])->count();
  24. }
  25. public function getDoctersAttribute($value)
  26. {
  27. return explode(',',$value);
  28. }
  29. public function setDoctersAttribute($value)
  30. {
  31. $this->attributes['docters'] = implode(',', $value);
  32. }
  33. }