Compare commits
50 Commits
Author | SHA1 | Date |
---|---|---|
Mahesh Sharma | 564529895f | 2 years ago |
Mahesh Sharma | cce8fd095a | 2 years ago |
tribikram | f860a36947 | 2 years ago |
Mahesh Sharma | 67612b1116 | 2 years ago |
tribikram | e269f8c285 | 2 years ago |
tribikram | a898a3fa78 | 2 years ago |
Mahesh Sharma | ca9688fb69 | 2 years ago |
Mahesh Sharma | f461b09d08 | 2 years ago |
tribikram | 401c406444 | 2 years ago |
tribikram | 6a0a4ccb34 | 2 years ago |
Mahesh Sharma | f2d67186be | 2 years ago |
Mahesh Sharma | 7f836f06c2 | 2 years ago |
Mahesh Sharma | 338d015069 | 2 years ago |
tribikram | 948b076c03 | 2 years ago |
tribikram | 1821580633 | 2 years ago |
tribikram | cf212411de | 2 years ago |
Mahesh Sharma | 4201b17cab | 2 years ago |
Mahesh Sharma | c5d88c4d03 | 2 years ago |
Mahesh Sharma | 92b515bd80 | 2 years ago |
tribikram | b3aaa90f34 | 2 years ago |
Mahesh Sharma | e1eb4fa70c | 2 years ago |
Mahesh Sharma | ed3918d02a | 2 years ago |
tribikram | 4a305d6a92 | 2 years ago |
tribikram | c4b87ab6c0 | 2 years ago |
tribikram | 3940ca697f | 2 years ago |
Mahesh Sharma | e7b33f2ccc | 2 years ago |
tribikram | 2520f2017b | 2 years ago |
Mahesh Sharma | e3210482fa | 2 years ago |
Mahesh Sharma | d310c517c1 | 2 years ago |
tribikram | c717c2cfe8 | 2 years ago |
tribikram | f8932a97c2 | 2 years ago |
Mahesh Sharma | f6118eeb1f | 2 years ago |
tribikram | ca5565d448 | 2 years ago |
tribikram | f5be1c14a7 | 2 years ago |
Mahesh Sharma | 98fb64971a | 2 years ago |
Mahesh Sharma | 45d0b8f609 | 2 years ago |
tribikram | c8f0fe2d1e | 2 years ago |
tribikram | f977c3ddb0 | 2 years ago |
Mahesh Sharma | 0c5354f9ce | 2 years ago |
Mahesh Sharma | 6023ac6817 | 2 years ago |
Mahesh Sharma | 3f2850b8d1 | 2 years ago |
suman | 25a9be6e1c | 2 years ago |
Mahesh Sharma | f053ba81b5 | 2 years ago |
Mahesh Sharma | 637e49f574 | 2 years ago |
Mahesh Sharma | 7952068dad | 2 years ago |
Mahesh Sharma | 7178c37eba | 2 years ago |
Mahesh Sharma | 77299944de | 2 years ago |
tribikram | 740c7e3953 | 2 years ago |
tribikram | 8d304d8bbf | 2 years ago |
Mahesh Sharma | 41f88d9e24 | 2 years ago |
@ -0,0 +1,36 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Console\Commands; |
||||||
|
|
||||||
|
use Illuminate\Console\Command; |
||||||
|
use Illuminate\Support\Facades\Queue; |
||||||
|
|
||||||
|
class CheckQueue extends Command |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The name and signature of the console command. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $signature = 'queue:check'; |
||||||
|
|
||||||
|
/** |
||||||
|
* The console command description. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $description = 'Check if there is a job in the queue'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the console command. |
||||||
|
* |
||||||
|
* @return int |
||||||
|
*/ |
||||||
|
public function handle() |
||||||
|
{ |
||||||
|
$count = Queue::size(); // Get the number of jobs in the queue |
||||||
|
if ($count > 0) { |
||||||
|
$this->call('queue:process'); // Call the ProcessQueue command if there is a job in the queue |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Console\Commands; |
||||||
|
|
||||||
|
use Illuminate\Console\Command; |
||||||
|
use Illuminate\Support\Facades\Queue; |
||||||
|
|
||||||
|
class ProcessQueue extends Command |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The name and signature of the console command. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $signature = 'queue:process'; |
||||||
|
|
||||||
|
/** |
||||||
|
* The console command description. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $description = 'Process the tasks in the queue'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the console command. |
||||||
|
* |
||||||
|
* @return int |
||||||
|
*/ |
||||||
|
public function handle() |
||||||
|
{ |
||||||
|
Queue::daemon(); // Process the tasks in the queue |
||||||
|
} |
||||||
|
} |
@ -1,278 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin; |
|
||||||
|
|
||||||
use App\Http\Controllers\Controller; |
|
||||||
use App\Models\Accomodation; |
|
||||||
use App\Models\BlogPoint; |
|
||||||
use App\Models\NewsAndUpdatePoint; |
|
||||||
use App\Models\Setting; |
|
||||||
use App\Models\User; |
|
||||||
use App\Models\AccomodationFeature; |
|
||||||
use App\Models\AccomodationInformation; |
|
||||||
use App\Models\AccomodationSliderTitle; |
|
||||||
use App\Models\AccomodationImage; |
|
||||||
use Illuminate\Http\Request; |
|
||||||
use Illuminate\Support\Facades\Auth; |
|
||||||
use Illuminate\Support\Facades\Session; |
|
||||||
// use function GuzzleHttp\Promise\all; |
|
||||||
|
|
||||||
class AccomodationController extends Controller |
|
||||||
{ |
|
||||||
protected $view = 'admin.accomodation.'; |
|
||||||
protected $redirect = 'admin/accomodations'; |
|
||||||
|
|
||||||
public function index() |
|
||||||
{ |
|
||||||
$settings = Accomodation::orderBy('id','DESC'); |
|
||||||
|
|
||||||
if(\request('name')){ |
|
||||||
$key = \request('name'); |
|
||||||
$settings = $settings->where('title','like','%'.$key.'%'); |
|
||||||
} |
|
||||||
if(\request('status')){ |
|
||||||
$key = \request('status'); |
|
||||||
$settings = $settings->where('status',$key); |
|
||||||
} |
|
||||||
$settings = $settings->paginate(config('custom.per_page')); |
|
||||||
return view($this->view.'index',compact('settings')); |
|
||||||
} |
|
||||||
|
|
||||||
public function create() |
|
||||||
{ |
|
||||||
return view($this->view . 'create'); |
|
||||||
} |
|
||||||
|
|
||||||
public function store(Request $request) |
|
||||||
{ |
|
||||||
|
|
||||||
$this->validate(\request(), [ |
|
||||||
'title' => 'required', |
|
||||||
'phone' => 'required', |
|
||||||
'address' => 'required', |
|
||||||
'status' => 'required', |
|
||||||
'images' => 'required', |
|
||||||
'slider_image' => 'required|file|mimes:jpeg,png,jpg' |
|
||||||
]); |
|
||||||
|
|
||||||
if($request->has('slider_image')){ |
|
||||||
|
|
||||||
$extension = \request()->file('slider_image')->getClientOriginalExtension(); |
|
||||||
$image_folder_type = array_search('accomodation',config('custom.image_folders')); //for image saved in folder |
|
||||||
$count = rand(100,999); |
|
||||||
$out_put_path = User::save_image(\request()->file('slider_image'),$extension,$count,$image_folder_type); |
|
||||||
$image_path1 = $out_put_path[0]; |
|
||||||
} |
|
||||||
|
|
||||||
$requestData = $request->all(); |
|
||||||
if(isset($image_path1)){ |
|
||||||
$requestData['slider_image'] = $image_path1; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
// $requestData['slug'] = Setting::create_slug($requestData['keyword']); |
|
||||||
$accomodation = Accomodation::create($requestData); |
|
||||||
|
|
||||||
if($request->hasFile('images')){ |
|
||||||
foreach($request->file('images') as $imagefile) { |
|
||||||
$extension = $imagefile->getClientOriginalExtension(); |
|
||||||
$image_folder_type = array_search('accomodation',config('custom.image_folders')); //for image saved in folder |
|
||||||
$count = rand(100,999); |
|
||||||
$out_put_path = User::save_image($imagefile,$extension,$count,$image_folder_type); |
|
||||||
$image_path1 = $out_put_path[0]; |
|
||||||
$accomodation_image = new AccomodationImage(); |
|
||||||
$accomodation_image->accomodation_id = $accomodation->id; |
|
||||||
$accomodation_image->image = $image_path1; |
|
||||||
$accomodation_image->save(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
if(\request('feature_name')){ |
|
||||||
foreach (\request('feature_name') as $index => $value){ |
|
||||||
$setting_point = new AccomodationFeature(); |
|
||||||
$setting_point->accomodation_id = $accomodation->id; |
|
||||||
$setting_point->feature_name = $value; |
|
||||||
$setting_point->save(); |
|
||||||
} |
|
||||||
} |
|
||||||
if(\request('information_name')){ |
|
||||||
foreach (\request('information_name') as $index => $value){ |
|
||||||
$setting_point = new AccomodationInformation(); |
|
||||||
$setting_point->accomodation_id = $accomodation->id; |
|
||||||
$setting_point->information_name = $value; |
|
||||||
$setting_point->save(); |
|
||||||
} |
|
||||||
} |
|
||||||
if(\request('title_name')){ |
|
||||||
foreach (\request('title_name') as $index => $value){ |
|
||||||
$setting_point = new AccomodationSliderTitle(); |
|
||||||
$setting_point->accomodation_id = $accomodation->id; |
|
||||||
$setting_point->title_name = $value; |
|
||||||
$setting_point->save(); |
|
||||||
} |
|
||||||
} |
|
||||||
Session::flash('success','Accomodation successfully created'); |
|
||||||
return redirect($this->redirect); |
|
||||||
} |
|
||||||
|
|
||||||
public function show($id) |
|
||||||
{ |
|
||||||
$setting =Accomodation::findorfail($id); |
|
||||||
return view($this->view.'show',compact('setting')); |
|
||||||
} |
|
||||||
|
|
||||||
public function edit($id){ |
|
||||||
$setting =Accomodation::findorfail($id); |
|
||||||
return view($this->view.'edit',compact('setting')); |
|
||||||
} |
|
||||||
|
|
||||||
public function update(Request $request, $id){ |
|
||||||
|
|
||||||
// dd(\request()->all()); |
|
||||||
$setting =Accomodation::findorfail($id); |
|
||||||
$this->validate(\request(), [ |
|
||||||
'title' => 'required', |
|
||||||
'phone' => 'required', |
|
||||||
'address' => 'required', |
|
||||||
'status' => 'required' |
|
||||||
// 'images' => 'required', |
|
||||||
// 'slider_image' => 'required|file|mimes:jpeg,png,jpg' |
|
||||||
]); |
|
||||||
|
|
||||||
if(\request('slider_image')){ |
|
||||||
$this->validate(\request(),[ |
|
||||||
'image' => 'file|mimes:jpeg,png,jpg' |
|
||||||
]); |
|
||||||
if($request->hasFile('slider_image')){ |
|
||||||
$extension = $request->file('slider_image')->getClientOriginalExtension(); |
|
||||||
$image_folder_type = array_search('accomodation',config('custom.image_folders')); //for image saved in folder |
|
||||||
$count = rand(100,999); |
|
||||||
$out_put_path = User::save_image($request->file('slider_image'),$extension,$count,$image_folder_type); |
|
||||||
$image_path1 = $out_put_path[0]; |
|
||||||
if (is_file(public_path().'/'.$setting->slider_image) && file_exists(public_path().'/'.$setting->slider_image)){ |
|
||||||
unlink(public_path().'/'.$setting->slider_image); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
$requestData = $request->all(); |
|
||||||
// $requestData['slug'] = Setting::create_slug($requestData['keyword']); |
|
||||||
if(isset($image_path1)){ |
|
||||||
$requestData['slider_image'] = $image_path1; |
|
||||||
} |
|
||||||
$setting->fill($requestData); |
|
||||||
if($setting->save()){ |
|
||||||
|
|
||||||
if($request->hasFile('images')){ |
|
||||||
|
|
||||||
$accommodation_image = $setting->accommodation_images(); |
|
||||||
$accommodation_image->delete(); |
|
||||||
foreach($request->file('images') as $imagefile) { |
|
||||||
$extension = $imagefile->getClientOriginalExtension(); |
|
||||||
$image_folder_type = array_search('accomodation',config('custom.image_folders')); //for image saved in folder |
|
||||||
$count = rand(100,999); |
|
||||||
$out_put_path = User::save_image($imagefile,$extension,$count,$image_folder_type); |
|
||||||
$image_path1 = $out_put_path[0]; |
|
||||||
// if (is_file(public_path().'/'.$setting->slider_image) && file_exists(public_path().'/'.$setting->slider_image)){ |
|
||||||
// unlink(public_path().'/'.$setting->slider_image); |
|
||||||
// } |
|
||||||
$accomodation_image = new AccomodationImage(); |
|
||||||
$accomodation_image->accomodation_id = $id; |
|
||||||
$accomodation_image->image = $image_path1; |
|
||||||
$accomodation_image->save(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
if(\request('feature_name') ){ |
|
||||||
$accommodation_feature = $setting->accommodation_features(); |
|
||||||
$accommodation_feature->delete(); |
|
||||||
foreach (\request('feature_name') as $index => $value){ |
|
||||||
$setting_point = new AccomodationFeature(); |
|
||||||
$setting_point->accomodation_id = $id; |
|
||||||
$setting_point->feature_name = $value; |
|
||||||
$setting_point->save(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if(\request('information_name') ){ |
|
||||||
$accommodation_information = $setting->accommodation_informations(); |
|
||||||
$accommodation_information->delete(); |
|
||||||
foreach (\request('information_name') as $index => $value){ |
|
||||||
$setting_point = new AccomodationInformation(); |
|
||||||
$setting_point->accomodation_id = $id; |
|
||||||
$setting_point->information_name = $value; |
|
||||||
$setting_point->save(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if(\request('title_name') ){ |
|
||||||
$accommodation_title = $setting->accommodation_slider_titles(); |
|
||||||
$accommodation_title->delete(); |
|
||||||
foreach (\request('title_name') as $index => $value){ |
|
||||||
$setting_point = new AccomodationSlidertitle(); |
|
||||||
$setting_point->accomodation_id = $id; |
|
||||||
$setting_point->title_name = $value; |
|
||||||
$setting_point->save(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
Session::flash('success','Accomodation succesffuly edited.'); |
|
||||||
return redirect($this->redirect); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public function delete($id){ |
|
||||||
$setting=Accomodation::findorfail($id); |
|
||||||
// if($setting->accommodation_features->count() > 0){ |
|
||||||
// $setting->accommodation_features()->delete(); |
|
||||||
// } |
|
||||||
// if($setting->accommodation_informations->count() > 0){ |
|
||||||
// $setting->accommodation_informations()->delete(); |
|
||||||
// } |
|
||||||
// if($setting->accommodation_slider_titles->count() > 0){ |
|
||||||
// $setting->accommodation_informations()->delete(); |
|
||||||
// } |
|
||||||
if($setting->delete()){ |
|
||||||
if (is_file(public_path().'/'.$setting->slider_image) && file_exists(public_path().'/'.$setting->slider_image)){ |
|
||||||
unlink(public_path().'/'.$setting->slider_image); |
|
||||||
} |
|
||||||
} |
|
||||||
Session::flash('success','Accomodation successfully is deleted !'); |
|
||||||
return redirect($this->redirect); |
|
||||||
} |
|
||||||
|
|
||||||
public function points_remove($id) |
|
||||||
{ |
|
||||||
if(Auth::user()){ |
|
||||||
$setting = AccomodationFeature::findorfail($id); |
|
||||||
$setting->delete(); |
|
||||||
return response()->json(['point_id' => $id]); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
public function information_points_remove($id) |
|
||||||
{ |
|
||||||
if(Auth::user()){ |
|
||||||
$setting = AccomodationInformation::findorfail($id); |
|
||||||
$setting->delete(); |
|
||||||
return response()->json(['point_id' => $id]); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
public function slider_points_remove($id) |
|
||||||
{ |
|
||||||
if(Auth::user()){ |
|
||||||
$setting = AccomodationSliderTitle::findorfail($id); |
|
||||||
$setting->delete(); |
|
||||||
return response()->json(['point_id' => $id]); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,155 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
|
||||||
|
|
||||||
|
use App\Models\Appointment; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Carbon\Carbon; |
||||||
|
|
||||||
|
class AppointmentController extends Controller |
||||||
|
{ |
||||||
|
protected $view = 'admin.appointment.'; |
||||||
|
protected $redirect = 'admin/appointments'; |
||||||
|
// protected $service; |
||||||
|
|
||||||
|
public function education_appointments() |
||||||
|
{ |
||||||
|
$appointments = Appointment::where('service_type', '1')->orderBy('id', 'DESC'); |
||||||
|
if (\request('date')) { |
||||||
|
$date = \request('date'); |
||||||
|
$appointments = $appointments->whereDate('date', $date); |
||||||
|
} |
||||||
|
if (\request('status')) { |
||||||
|
$status = \request('status'); |
||||||
|
$appointments = $appointments->where('status', $status); |
||||||
|
} |
||||||
|
if (\request('is_booked')) { |
||||||
|
$is_booked = (\request('is_booked')) == '1' ? true : false; |
||||||
|
$appointments = $appointments->where('is_booked', $is_booked); |
||||||
|
} |
||||||
|
$appointments = $appointments->paginate(20); |
||||||
|
$service = 'Education'; |
||||||
|
$is_booked = $is_booked ?? null; |
||||||
|
$date = $date ?? null; |
||||||
|
$status = $status ?? null; |
||||||
|
return view($this->view . 'index', compact('appointments', 'service', 'is_booked', 'date', 'status')); |
||||||
|
} |
||||||
|
|
||||||
|
public function visa_appointments() |
||||||
|
{ |
||||||
|
$appointments = Appointment::where('service_type', '2')->orderBy('id', 'DESC'); |
||||||
|
if (\request('date')) { |
||||||
|
$date = \request('date'); |
||||||
|
$appointments = $appointments->whereDate('date', $date); |
||||||
|
} |
||||||
|
if (\request('status')) { |
||||||
|
$status = \request('status'); |
||||||
|
$appointments = $appointments->where('status', $status); |
||||||
|
} |
||||||
|
if (\request('is_booked')) { |
||||||
|
|
||||||
|
$is_booked = (\request('is_booked')) == '1' ? true : false; |
||||||
|
$appointments = $appointments->where('is_booked', $is_booked); |
||||||
|
} |
||||||
|
$appointments = $appointments->paginate(20); |
||||||
|
$is_booked = $is_booked ?? null; |
||||||
|
$date = $date ?? null; |
||||||
|
$status = $status ?? null; |
||||||
|
$service = 'Migration|Visa'; |
||||||
|
return view($this->view . 'index', compact('appointments', 'service', 'is_booked', 'date', 'status')); |
||||||
|
} |
||||||
|
|
||||||
|
public function create() |
||||||
|
{ |
||||||
|
return view($this->view . 'create'); |
||||||
|
} |
||||||
|
|
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
$request->validate([ |
||||||
|
'date' => 'required|date', |
||||||
|
'start_time' => 'required|date_format:H:i', |
||||||
|
'end_time' => 'required|date_format:H:i', |
||||||
|
]); |
||||||
|
$start_time = Carbon::createFromFormat('H:i', $request->get('start_time'))->format('H:i A'); |
||||||
|
$end_time = Carbon::createFromFormat('H:i', $request->get('end_time'))->format('H:i A'); |
||||||
|
|
||||||
|
$appointment = new Appointment([ |
||||||
|
'date' => $request->get('date'), |
||||||
|
'start_time' => $start_time, |
||||||
|
'end_time' => $end_time, |
||||||
|
'location' => $request->get('location'), |
||||||
|
'description' => $request->get('description'), |
||||||
|
'service_type' => $request->get('service_type'), |
||||||
|
]); |
||||||
|
|
||||||
|
$appointment->save(); |
||||||
|
if($request->get('service_type') == "1"){ |
||||||
|
$service = 'education'; |
||||||
|
}else{ |
||||||
|
$service = 'visa'; |
||||||
|
} |
||||||
|
|
||||||
|
return redirect($this->redirect.'/'.$service)->with('success', 'Appointment has been added'); |
||||||
|
} |
||||||
|
|
||||||
|
public function edit($id) |
||||||
|
{ |
||||||
|
$appointment = Appointment::findorfail($id); |
||||||
|
$start_time = explode(" ", $appointment->start_time); |
||||||
|
$start_time = $start_time[0]; |
||||||
|
|
||||||
|
$end_time = explode(" ", $appointment->end_time); |
||||||
|
$end_time = $end_time[0]; |
||||||
|
$appointment['start_time'] = $start_time; |
||||||
|
$appointment['end_time'] = $end_time; |
||||||
|
return view($this->view . 'edit', compact('appointment')); |
||||||
|
} |
||||||
|
|
||||||
|
public function update(Request $request, $id) |
||||||
|
{ |
||||||
|
|
||||||
|
$request->validate([ |
||||||
|
'date' => 'required|date', |
||||||
|
'start_time' => 'required|date_format:H:i', |
||||||
|
'end_time' => 'required|date_format:H:i', |
||||||
|
]); |
||||||
|
$start_time = Carbon::createFromFormat('H:i', $request->get('start_time'))->format('H:i A'); |
||||||
|
$end_time = Carbon::createFromFormat('H:i', $request->get('end_time'))->format('H:i A'); |
||||||
|
|
||||||
|
$appointment = Appointment::find($id); |
||||||
|
$appointment->date = $request->get('date'); |
||||||
|
$appointment->start_time = $start_time; |
||||||
|
$appointment->end_time = $end_time; |
||||||
|
$appointment->location = $request->get('location'); |
||||||
|
$appointment->description = $request->get('description'); |
||||||
|
$appointment->service_type = $request->get('service_type'); |
||||||
|
$appointment->status = $request->get('status'); |
||||||
|
$appointment->save(); |
||||||
|
if($request->get('service_type') == "1"){ |
||||||
|
$service = 'education'; |
||||||
|
}else{ |
||||||
|
$service = 'visa'; |
||||||
|
} |
||||||
|
|
||||||
|
return redirect($this->redirect.'/'.$service)->with('success', 'Appointment has been updated'); |
||||||
|
} |
||||||
|
|
||||||
|
public function show($id) |
||||||
|
{ |
||||||
|
$appointment = Appointment::with('appointment_booking_detail')->findorfail($id); |
||||||
|
|
||||||
|
return view($this->view . 'show', compact('appointment')); |
||||||
|
} |
||||||
|
|
||||||
|
public function destroy($id) |
||||||
|
{ |
||||||
|
$appointment = Appointment::find($id); |
||||||
|
$appointment->delete(); |
||||||
|
|
||||||
|
return redirect($this->redirect)->with('success', 'Appointment has been deleted'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,145 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
use App\Models\Appointment; |
||||||
|
use Carbon\Carbon; |
||||||
|
use App\Models\AppointmentBookingDetail; |
||||||
|
|
||||||
|
class AppointmentController extends Controller |
||||||
|
{ |
||||||
|
public function index(){ |
||||||
|
|
||||||
|
$educationAppointments = Appointment::where('date', '>=', Carbon::today())->where('service_type', '1')->get(); |
||||||
|
$visaAppointments = Appointment::where('date', '>=', Carbon::today())->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'); |
||||||
|
|
||||||
|
$type_id = $request->id; |
||||||
|
$appointments_all = Appointment::whereDate('date',$date)->where(['service_type' => $type_id,'is_booked' => false,'status' => 1])->get(); |
||||||
|
$old_date = Carbon::createFromFormat('Y-m-d', $date); |
||||||
|
$formated_date = $old_date->format('M d, Y'); |
||||||
|
$currentTime = Carbon::now(); |
||||||
|
$appointments = []; |
||||||
|
foreach ($appointments_all as $appointment) { |
||||||
|
$start_time = explode(" ", $appointment->start_time); |
||||||
|
$start_time = $start_time[0]; |
||||||
|
$appointmentDate = Carbon::createFromFormat('Y-m-d H:i', $appointment->date.' '.$start_time); |
||||||
|
if ($appointmentDate->gt($currentTime)) { |
||||||
|
array_push($appointments, $appointment); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return response()->json(['appointment' => $appointments,'formated_date' => $formated_date]); |
||||||
|
} |
||||||
|
|
||||||
|
public function form_submit(Request $request){ |
||||||
|
|
||||||
|
$request->validate([ |
||||||
|
'name' => 'required', |
||||||
|
'email' => 'required|email', |
||||||
|
'phone' => 'required', |
||||||
|
]); |
||||||
|
$appointment_id = $request->get('appointment_id'); |
||||||
|
|
||||||
|
$appointment = Appointment::findorfail($appointment_id); |
||||||
|
$appointment_detail = new AppointmentBookingDetail(); |
||||||
|
$appointment_detail->name = $request->get('name'); |
||||||
|
$appointment_detail->email = $request->get('email'); |
||||||
|
$appointment_detail->phone = $request->get('phone'); |
||||||
|
$appointment_detail->notes = $request->get('notes'); |
||||||
|
$appointment_detail->appointment_id = $appointment_id; |
||||||
|
$email = $request['email']; |
||||||
|
$name = $request['name']; |
||||||
|
$phone = $request['phone']; |
||||||
|
|
||||||
|
if($appointment_detail->save()){ |
||||||
|
|
||||||
|
$date = Carbon::createFromFormat('Y-m-d', $appointment->date); |
||||||
|
$formated_date = $date->format('M d, Y'); |
||||||
|
$appointment->is_booked = true; |
||||||
|
$appointment->save(); |
||||||
|
$subject = 'Appointment Booked Successfully.'; |
||||||
|
dispatch(function() use ($name,$email,$phone,$subject,$formated_date,$appointment) { |
||||||
|
|
||||||
|
\Mail::send('appointment_confirmed', array( |
||||||
|
|
||||||
|
'full_name' =>$name, |
||||||
|
|
||||||
|
'email' =>$email, |
||||||
|
|
||||||
|
'date' => $formated_date, |
||||||
|
|
||||||
|
'start_time' => $appointment['start_time'], |
||||||
|
|
||||||
|
'end_time' => $appointment['end_time'], |
||||||
|
|
||||||
|
'phone' =>$phone, |
||||||
|
|
||||||
|
'subject' =>$subject |
||||||
|
|
||||||
|
|
||||||
|
), function($message) use ($subject,$email,$name){ |
||||||
|
// $subject=($service!= '') ? 'Enquiry for '.$service : 'Contact/Feedback'; |
||||||
|
$message->subject($subject); |
||||||
|
// $message->from('admin@eteducation.com.au', 'Admin'); |
||||||
|
$message->to($email, $name)->subject($subject); |
||||||
|
// $message->cc('extratechweb@gmail.com', 'Extratech')->subject($subject); |
||||||
|
// $message->cc('admin@eteducation.com.au', 'Extratech')->subject($subject); |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
dispatch(function() use ($name,$email,$phone,$subject,$formated_date,$appointment) { |
||||||
|
|
||||||
|
\Mail::send('appointment_confirmed_for_admin', array( |
||||||
|
|
||||||
|
'full_name' =>$name, |
||||||
|
|
||||||
|
'email' =>$email, |
||||||
|
|
||||||
|
'date' => $formated_date, |
||||||
|
|
||||||
|
'start_time' => $appointment['start_time'], |
||||||
|
|
||||||
|
'end_time' => $appointment['end_time'], |
||||||
|
|
||||||
|
'phone' =>$phone, |
||||||
|
|
||||||
|
'subject' =>$subject |
||||||
|
|
||||||
|
), function($message) use ($subject){ |
||||||
|
// $subject=($service!= '') ? 'Enquiry for '.$service : 'Contact/Feedback'; |
||||||
|
$message->subject($subject); |
||||||
|
// $message->to($email, $name)->subject($subject); |
||||||
|
$message->to('mahesh@extratechs.com.au', 'Extratech')->subject($subject); |
||||||
|
// $message->cc('admin@eteducation.com.au', 'Extratech')->subject($subject); |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
return response()->json(['appointment_detail' => $appointment_detail,'appointment' => $appointment,'formated_date' => $formated_date],200); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use App\Jobs\SendEnquiryMailJob; |
||||||
|
use App\Models\Country; |
||||||
|
use App\Models\Enquiry; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\DB; |
||||||
|
use Illuminate\Support\Facades\Session; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class EnquiryController extends Controller |
||||||
|
{ |
||||||
|
public function form() |
||||||
|
{ |
||||||
|
$countries = Country::all(); |
||||||
|
return view('enquiry-form', compact('countries')); |
||||||
|
} |
||||||
|
|
||||||
|
public function submit(Request $request) |
||||||
|
{ |
||||||
|
$work_experience = $request->get('work_experience'); |
||||||
|
if ($work_experience == 'no') { |
||||||
|
$request['work_experience_details'] = null; |
||||||
|
$request['salary_mode'] = null; |
||||||
|
} |
||||||
|
$marital_status = $request->get('marital_status'); |
||||||
|
if ($marital_status == 'Widow' || $marital_status == 'Single') { |
||||||
|
$request['married_date'] = null; |
||||||
|
$request['spouse_academics'] = null; |
||||||
|
$request['spouse_work_experience'] = null; |
||||||
|
$request['spouse_salary_mode'] = null; |
||||||
|
} |
||||||
|
DB::beginTransaction(); |
||||||
|
try { |
||||||
|
$enquiry = Enquiry::create($request->all()); |
||||||
|
} catch (\Exception $e) { |
||||||
|
DB::rollback(); |
||||||
|
return redirect()->back()->with(['msg' => 'Something went wrong. Please try again!', 'status' => false], 400); |
||||||
|
} |
||||||
|
DB::commit(); |
||||||
|
dispatch(new SendEnquiryMailJob($enquiry)); |
||||||
|
return redirect()->back()->with(['msg' => 'We have recieved your enquiry. You will be contacted soon!', 'status' => true], 200); |
||||||
|
} |
||||||
|
|
||||||
|
public function index() |
||||||
|
{ |
||||||
|
|
||||||
|
$enquiries = Enquiry::orderBy('id', 'DESC'); |
||||||
|
if (\request('name')) { |
||||||
|
$key = \request('name'); |
||||||
|
$enquiries = $enquiries->where('first_name', 'like', $key . '%'); |
||||||
|
} |
||||||
|
if (\request('email')) { |
||||||
|
$key = \request('email'); |
||||||
|
$enquiries = $enquiries->where('email', 'like', $key . '%'); |
||||||
|
} |
||||||
|
$enquiries = $enquiries->paginate(30); |
||||||
|
return view('admin.enquiry.index', compact('enquiries')); |
||||||
|
} |
||||||
|
|
||||||
|
public function show($id) |
||||||
|
{ |
||||||
|
$enquiry = Enquiry::findorfail($id); |
||||||
|
return view('admin.enquiry.show', compact('enquiry')); |
||||||
|
} |
||||||
|
public function delete($id) |
||||||
|
{ |
||||||
|
$enquiry = Enquiry::findorfail($id); |
||||||
|
$enquiry->delete(); |
||||||
|
Session::flash('success', 'Enquiry has been successfully deleted!'); |
||||||
|
return redirect('admin/enquiries'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Jobs; |
||||||
|
|
||||||
|
use App\Mail\EnquiryMail; |
||||||
|
use App\Models\Setting; |
||||||
|
use Illuminate\Bus\Queueable; |
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
use Illuminate\Foundation\Bus\Dispatchable; |
||||||
|
use Illuminate\Queue\InteractsWithQueue; |
||||||
|
use Illuminate\Queue\SerializesModels; |
||||||
|
use Illuminate\Support\Facades\Mail; |
||||||
|
|
||||||
|
class SendEnquiryMailJob implements ShouldQueue |
||||||
|
{ |
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new job instance. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
protected $enquiry; |
||||||
|
public function __construct($enquiry) |
||||||
|
{ |
||||||
|
$this->enquiry = $enquiry; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the job. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function handle() |
||||||
|
{ |
||||||
|
$email = Setting::where('key', 'email')->get('value')->first()->value; |
||||||
|
|
||||||
|
Mail::to($email)->send(new EnquiryMail($this->enquiry)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Mail; |
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
use Illuminate\Mail\Mailable; |
||||||
|
use Illuminate\Mail\Mailables\Content; |
||||||
|
use Illuminate\Mail\Mailables\Envelope; |
||||||
|
use Illuminate\Queue\SerializesModels; |
||||||
|
|
||||||
|
class EnquiryMail extends Mailable |
||||||
|
{ |
||||||
|
use Queueable, SerializesModels; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new message instance. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
* |
||||||
|
*/ |
||||||
|
protected $enquiry; |
||||||
|
|
||||||
|
public function __construct($enquiry) |
||||||
|
{ |
||||||
|
$this->enquiry = $enquiry; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the message envelope. |
||||||
|
* |
||||||
|
* @return \Illuminate\Mail\Mailables\Envelope |
||||||
|
*/ |
||||||
|
public function envelope() |
||||||
|
{ |
||||||
|
return new Envelope( |
||||||
|
subject: 'Enquiry Mail', |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the message content definition. |
||||||
|
* |
||||||
|
* @return \Illuminate\Mail\Mailables\Content |
||||||
|
*/ |
||||||
|
public function content() |
||||||
|
{ |
||||||
|
return new Content( |
||||||
|
view: 'enquiry_mail', |
||||||
|
with: [ |
||||||
|
'enquiry' => $this->enquiry, |
||||||
|
], |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the attachments for the message. |
||||||
|
* |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public function attachments() |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class Appointment extends Model |
||||||
|
{ |
||||||
|
use HasFactory; |
||||||
|
|
||||||
|
protected $guarded = ['id']; |
||||||
|
|
||||||
|
public function appointment_booking_detail(){ |
||||||
|
return $this->hasOne(AppointmentBookingDetail::class); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class AppointmentBookingDetail extends Model |
||||||
|
{ |
||||||
|
use HasFactory; |
||||||
|
|
||||||
|
public function appointment(){ |
||||||
|
return $this->belongsTo(Appointment::class); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class Country extends Model |
||||||
|
{ |
||||||
|
use HasFactory; |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class Enquiry extends Model |
||||||
|
{ |
||||||
|
use HasFactory; |
||||||
|
|
||||||
|
protected $guarded = ['id']; |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
<?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::create('appointments', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->date('date'); |
||||||
|
$table->string('start_time'); |
||||||
|
$table->string('end_time'); |
||||||
|
$table->string('location')->nullable(); |
||||||
|
$table->string('description')->nullable(); |
||||||
|
$table->enum('status',[1,2]); |
||||||
|
$table->timestamps(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function down() |
||||||
|
{ |
||||||
|
Schema::dropIfExists('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) { |
||||||
|
// |
||||||
|
}); |
||||||
|
} |
||||||
|
}; |
@ -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->boolean('is_booked')->default(false); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function down() |
||||||
|
{ |
||||||
|
Schema::table('appointments', function (Blueprint $table) { |
||||||
|
// |
||||||
|
}); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,37 @@ |
|||||||
|
<?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::create('appointment_booking_details', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->bigInteger('appointment_id')->unsigned(); |
||||||
|
$table->foreign('appointment_id')->references('id')->on('appointments')->onDelete('cascade'); |
||||||
|
$table->string('name'); |
||||||
|
$table->string('email')->nullable(); |
||||||
|
$table->string('phone'); |
||||||
|
$table->string('notes')->nullable(); |
||||||
|
$table->timestamps(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function down() |
||||||
|
{ |
||||||
|
Schema::dropIfExists('appointment_booking_details'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,59 @@ |
|||||||
|
<?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::create('enquiries', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->string('first_name'); |
||||||
|
$table->string('middle_name')->nullable(); |
||||||
|
$table->string('last_name'); |
||||||
|
$table->date('dob'); |
||||||
|
$table->string('cob'); |
||||||
|
$table->string('gender'); |
||||||
|
$table->string('email'); |
||||||
|
$table->string('phone'); |
||||||
|
$table->string('address'); |
||||||
|
$table->string('highest_qualification'); |
||||||
|
$table->string('stream')->nullable(); |
||||||
|
$table->string('gpa'); |
||||||
|
$table->string('graduate_year'); |
||||||
|
$table->string('gap')->nullable(); |
||||||
|
$table->string('current_status')->nullable(); |
||||||
|
$table->string('work_experience'); |
||||||
|
$table->text('work_experience_details')->nullable(); |
||||||
|
$table->string('salary_mode')->nullable(); |
||||||
|
$table->string('test_score')->nullable(); |
||||||
|
$table->string('marital_status'); |
||||||
|
$table->string('married_date')->nullable(); |
||||||
|
$table->string('spouse_academics')->nullable(); |
||||||
|
$table->string('spouse_work_experience')->nullable(); |
||||||
|
$table->string('spouse_salary_mode')->nullable(); |
||||||
|
$table->string('immigration_history')->nullable(); |
||||||
|
$table->string('desired_study_field')->nullable(); |
||||||
|
$table->string('desired_location')->nullable(); |
||||||
|
$table->boolean('status')->default(true); |
||||||
|
$table->timestamps(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function down() |
||||||
|
{ |
||||||
|
Schema::dropIfExists('enquiries'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,49 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Database\Seeders; |
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents; |
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
use App\Models\Appointment; |
||||||
|
use Carbon\Carbon; |
||||||
|
use Carbon\CarbonInterval; |
||||||
|
use Illuminate\Support\Facades\DB; |
||||||
|
|
||||||
|
|
||||||
|
class AppointmentTableSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function run() |
||||||
|
{ |
||||||
|
|
||||||
|
$latestAppointment = DB::table('appointments')->latest('date')->first(); |
||||||
|
$startDate = $latestAppointment ? Carbon::parse($latestAppointment->date)->addDay() : Carbon::now(); |
||||||
|
|
||||||
|
$startTime = Carbon::parse("9:00 AM"); |
||||||
|
$endTime = Carbon::parse("5:00 PM"); |
||||||
|
|
||||||
|
foreach(config('custom.service_type') as $key => $value){ |
||||||
|
|
||||||
|
for ($i = 0; $i < 7; $i++) { |
||||||
|
$date = $startDate->copy()->addDays($i); |
||||||
|
for ($j = 0; $j <= ((($endTime->diffInMinutes($startTime)) / 30)-1); $j++) { |
||||||
|
|
||||||
|
$currentTime = $startTime->copy()->addMinutes(30 * $j); |
||||||
|
$currentEndTime = $startTime->copy()->addMinutes(30 * $j + 30); |
||||||
|
|
||||||
|
DB::table('appointments')->insert([ |
||||||
|
'date' => $date, |
||||||
|
'start_time' => $currentTime->format("H:i A"), |
||||||
|
'end_time' => $currentEndTime->format("H:i A"), |
||||||
|
'service_type' => $key |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Before Width: | Height: | Size: 460 KiB |
After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 389 KiB |
After Width: | Height: | Size: 1.0 MiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 394 KiB |
Before Width: | Height: | Size: 394 KiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 460 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 389 KiB |
Before Width: | Height: | Size: 389 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 441 KiB After Width: | Height: | Size: 441 KiB |
Before Width: | Height: | Size: 441 KiB After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 500 KiB |
After Width: | Height: | Size: 431 KiB |
After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 389 KiB |
After Width: | Height: | Size: 572 KiB |
After Width: | Height: | Size: 610 KiB |
After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 389 KiB |
Before Width: | Height: | Size: 389 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 932 KiB |
After Width: | Height: | Size: 572 KiB |
After Width: | Height: | Size: 431 KiB |
After Width: | Height: | Size: 405 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 14 KiB |