Commit 5c0af401 by lujunyi

返回完整图片

parent 4e8109d8
......@@ -189,6 +189,7 @@ public function upload(Request $request)
if ($pharmacist->save()) {
return $this->success(['message' => 'ok', 'url' => $imageUrl]);
}
return $this->failed('签名图片上传失败');
} else {
return $this->failed('签名图片上传失败');
......
......@@ -175,9 +175,8 @@ public function create(Request $request)
if (intval($prescription_limit) > 0) {
$startOfDay = Carbon::now()->startOfDay();
$endOfDay = Carbon::now()->endOfDay();
$doctorIds = DoctorModel::query()->where('status', 1)->pluck('id')->toArray();
$prescriptionCounts = DB::table('prescription')
->select('doctor_id', DB::raw('COUNT(*) as prescription_count'))
$doctorIds = DoctorModel::query()->where('status', DoctorModel::STATUS_TRUE)->pluck('id')->toArray();
$prescriptionCounts = PrescriptionModel::select('doctor_id', DB::raw('COUNT(*) as prescription_count'))
->whereIn('doctor_id', $doctorIds)
->whereBetween('created_at', [$startOfDay, $endOfDay])
->groupBy('doctor_id')
......@@ -188,13 +187,13 @@ public function create(Request $request)
return $prescriptionCounts->get($doctorId, 0) < $prescription_limit;
})->values()->all();
// 随机取一个随机医师
$randomDoctor = DB::table('doctor')
->whereIn('id', $availableDoctors)
$randomDoctor = DoctorModel::whereIn('id', $availableDoctors)
->where('status', DoctorModel::STATUS_TRUE)
->inRandomOrder()
->first();
} else {
$randomDoctor = DoctorModel::inRandomOrder()->where('status', 1)->first();
$randomDoctor = DoctorModel::inRandomOrder()->where('status', DoctorModel::STATUS_TRUE)->first();
}
$prescription->doctor_id = $randomDoctor->id;
......
......@@ -15,6 +15,17 @@ class DoctorModel extends Model
protected $table = 'doctor';
// 医师状态[0=启用,1=禁用]
const STATUS_FALSE = 0;
const STATUS_TRUE = 1;
// 医师状态-文字映射
const STATUS_MAP = [
self::STATUS_FALSE => '禁用',
self::STATUS_TRUE => '启用',
];
// 医师所属于的用户,一对一
public function user()
{
......
......@@ -21,6 +21,24 @@ public function pharmacy()
return $this->belongsTo(PharmacyModel::class, 'pharmacy_id', 'id');
}
public function getPracticingLicenseAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getPhysicianLicenseAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getSignedPicAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment