parent
740c7e3953
commit
77299944de
9 changed files with 241 additions and 38 deletions
@ -0,0 +1,41 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Models\Appointment; |
||||
use Carbon\Carbon; |
||||
|
||||
class AppointmentController extends Controller |
||||
{ |
||||
public function index(){ |
||||
|
||||
$educationAppointments = Appointment::where('service_type', '1')->get(); |
||||
$visaAppointments = Appointment::where('service_type', '2')->get(); |
||||
// foreach($educationAppointments as $appointment){ |
||||
// $startTime = Carbon::createFromFormat('H:i', $appointment->start_time); |
||||
// $date = Carbon::createFromFormat('H:i', $appointment->start_time); |
||||
// dd($date); |
||||
// } |
||||
return view('appointment', compact('educationAppointments', 'visaAppointments')); |
||||
|
||||
} |
||||
|
||||
public function get_appointment_by_date(Request $request){ |
||||
$dateTime = $request->date; |
||||
$date_parts = explode(" ", $dateTime); |
||||
$month_number = date_parse($date_parts[1])['month']; |
||||
$carbon = Carbon::createFromDate($date_parts[3], $month_number, $date_parts[2]); |
||||
|
||||
$date = $carbon->format('Y-m-d'); |
||||
|
||||
$appointments = Appointment::whereDate('date',$date)->where('status',1)->get(); |
||||
// $users = DB::table('appointments')->whereDate('created_at', '2022-12-01')->get(); |
||||
// $time = []; |
||||
// foreach($appointments as $appointment){ |
||||
// array_push($time, [$appointment->start_time, $appointment->id]); |
||||
// } |
||||
// dd($time); |
||||
return response()->json(['appointment' => $appointments]); |
||||
} |
||||
} |
@ -0,0 +1,32 @@ |
||||
<?php |
||||
|
||||
use Illuminate\Database\Migrations\Migration; |
||||
use Illuminate\Database\Schema\Blueprint; |
||||
use Illuminate\Support\Facades\Schema; |
||||
|
||||
return new class extends Migration |
||||
{ |
||||
/** |
||||
* Run the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function up() |
||||
{ |
||||
Schema::table('appointments', function (Blueprint $table) { |
||||
$table->enum('service_type',[1,2]); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Reverse the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function down() |
||||
{ |
||||
Schema::table('appointments', function (Blueprint $table) { |
||||
// |
||||
}); |
||||
} |
||||
}; |
Loading…
Reference in new issue