implementing-task-scheduler

master
Mahesh Sharma 2 years ago
parent cce8fd095a
commit 564529895f
  1. 36
      app/Console/Commands/CheckQueue.php
  2. 33
      app/Console/Commands/ProcessQueue.php
  3. 2
      app/Console/Kernel.php
  4. 19
      app/Http/Controllers/Admin/AppointmentController.php
  5. 39
      app/Http/Controllers/AppointmentController.php
  6. 9
      app/Http/Controllers/HomeController.php

@ -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
}
}

@ -15,7 +15,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('queue:check')->everyMinute();
}
/**

@ -73,11 +73,10 @@ class AppointmentController extends Controller
'date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_time' => 'required|date_format:H:i',
// 'location' => 'required|max:255',
// 'description' => 'required',
]);
$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,
@ -88,8 +87,13 @@ class AppointmentController extends Controller
]);
$appointment->save();
if($request->get('service_type') == "1"){
$service = 'education';
}else{
$service = 'visa';
}
return redirect($this->redirect)->with('success', 'Appointment has been added');
return redirect($this->redirect.'/'.$service)->with('success', 'Appointment has been added');
}
public function edit($id)
@ -107,7 +111,7 @@ class AppointmentController extends Controller
public function update(Request $request, $id)
{
dd($request->all());
$request->validate([
'date' => 'required|date',
'start_time' => 'required|date_format:H:i',
@ -125,8 +129,13 @@ class AppointmentController extends Controller
$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)->with('success', 'Appointment has been updated');
return redirect($this->redirect.'/'.$service)->with('success', 'Appointment has been updated');
}
public function show($id)

@ -96,10 +96,41 @@ class AppointmentController extends Controller
), function($message) use ($subject,$email,$name){
// $subject=($service!= '') ? 'Enquiry for '.$service : 'Contact/Feedback';
$message->subject($subject);
$message->to($email, $name)->subject($subject);
// $message->cc('extratechweb@gmail.com', 'Extratech')->subject($subject);
// $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);
});

@ -18,15 +18,16 @@ class HomeController extends Controller
}
public function runQueueJobs(){
Artisan::call('queue:listen');
}
public function index(){
}
public function index(){
$sliders = Slider::where('status',1)->get();
$testimonials = Testimonial::where('status',1)->get();
$blogs = NewsAndUpdate::where('status',1)->get();
$about_us = AboutUs::where('status',1)->get();
return view('welcome',compact('sliders','testimonials','blogs','about_us'));
}
public function subscribe(Request $request)
}
public function subscribe(Request $request)
{
$email = $request->email;

Loading…
Cancel
Save