Implement seeders instead of seeding using migrations, log whatasapp message
This commit is contained in:
@@ -104,19 +104,22 @@ class SettingController extends Controller
|
||||
// flushed the fail job in queueu
|
||||
Artisan::call('queue:flush');
|
||||
|
||||
$getClassNameString = function($className){
|
||||
$ola = explode("\\", $className);
|
||||
return end($ola);
|
||||
$getClassNameString = function ($className) {
|
||||
$name = explode("\\", $className);
|
||||
return end($name);
|
||||
};
|
||||
|
||||
DB::connection('mysql7')
|
||||
->table('jobs')
|
||||
->where('payload', 'like', '%' . $getClassNameString(WhatsappUnsoldCommodityNotification::class) . '%')
|
||||
->delete();
|
||||
$commodityNotificationClasses = [
|
||||
WhatsappUnsoldCommodityNotification::class,
|
||||
WhatsappUnsoldCommodityScanner::class,
|
||||
];
|
||||
|
||||
DB::connection('mysql7')
|
||||
->table('jobs')
|
||||
->where('payload', 'like', '%' . $getClassNameString(WhatsappUnsoldCommodityScanner::class) . '%')
|
||||
->delete();
|
||||
|
||||
foreach ($commodityNotificationClasses as $class) {
|
||||
DB::connection('mysql7')
|
||||
->table('jobs')
|
||||
->where('payload', 'like', '%' . $getClassNameString($class) . '%')
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\BlastWasap;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Setting;
|
||||
use Carbon\Carbon;
|
||||
@@ -64,20 +65,35 @@ class WhatsappUnsoldCommodityNotification extends Job
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (!$isKomoditiStillAvailable) {
|
||||
// return false;
|
||||
// }
|
||||
if (!$isKomoditiStillAvailable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($phone_numbers as $phone_number) {
|
||||
Http::get(env('WABOT_API'), [
|
||||
$response = Http::get(env('WABOT_API'), [
|
||||
'number' => $phone_number,
|
||||
'type' => 'text',
|
||||
'message' => $message,
|
||||
'instance_id' => env('WABOT_INSTANCES_ID'),
|
||||
'access_token' => env('WABOT_TOKEN_KEYS')
|
||||
]);
|
||||
|
||||
|
||||
//insert log blast wasap
|
||||
$logblastwasap = new BlastWasap();
|
||||
$logblastwasap->kodcaw = 'OPERASI';
|
||||
$logblastwasap->notelefon = $phone_number;
|
||||
$logblastwasap->norujukan = 'Notifikasi Komoditi Tidak Terjual';
|
||||
$logblastwasap->status = $response;
|
||||
$logblastwasap->created_at = Carbon::now();
|
||||
$logblastwasap->updated_at = Carbon::now();
|
||||
$logblastwasap->save();
|
||||
|
||||
Log::info("WABOT - Notifikasi Komoditi Tidak Terjual".$response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
dispatch((new WhatsappUnsoldCommodityNotification($this->message))->delay(Carbon::now()->addMinutes(5)));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user