增加可预约时间范围设置

main
yanzai 2 years ago
parent d698776237
commit d8acea60d4

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Appointment; use App\Models\Appointment;
use App\Models\AppointmentHolidays; use App\Models\AppointmentHolidays;
use App\Models\AppointmentTemplate; use App\Models\AppointmentTemplate;
use App\Models\Config;
use App\Models\Hospital; use App\Models\Hospital;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Login; use Login;
@ -269,13 +270,24 @@ class AppointmentController extends Controller
Login::user(); Login::user();
$month = $request->post('month'); $month = $request->post('month');
$hospital = $request->post('hospital'); $hospital = $request->post('hospital');
// var_dump($sevenDaysLater);
$appointments = Appointment::where('hospital', $hospital) $appointments = Appointment::where('hospital', $hospital)
->where('date', 'like', $month . '%') ->where('date', 'like', $month . '%');
$config=Config::where('label','预约时间范围')->first();
if(!!$config and $config->value>0){
$range = date('Y-m-d', strtotime('+'.$config->value.' days')); //N天后的日期
$appointments=$appointments ->where('date', '<=', $range);
}
$appointments=$appointments
->where('status', 1) ->where('status', 1)
->where('del', 2) ->where('del', 2)
->orderBy('date') ->orderBy('date')
->orderBy('start_time') ->orderBy('start_time')
->get(); ->get();
$list = []; $list = [];
foreach ($appointments as $appointment) { foreach ($appointments as $appointment) {
$date = substr($appointment->date, 8, 2); $date = substr($appointment->date, 8, 2);

Loading…
Cancel
Save