mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 23:50:33 +00:00
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Livewire\Component;
|
|
|
|
class JobQueueNotifications extends Component
|
|
{
|
|
|
|
public function render(): View
|
|
{
|
|
|
|
$jobs = [];
|
|
$getJobs = DB::table('jobs')->orderBy('id', 'desc')->get();
|
|
foreach ($getJobs as $job) {
|
|
$job->payload = json_decode($job->payload);
|
|
if (isset($job->payload->displayName)) {
|
|
$jobClassInstance = new $job->payload->displayName;
|
|
$displayName = 'Unknown Job';
|
|
if (method_exists($jobClassInstance, 'getDisplayName')) {
|
|
$displayName = $jobClassInstance->getDisplayName();
|
|
} else {
|
|
$explodeDisplayName = explode('\\', $job->payload->displayName);
|
|
$displayName = end($explodeDisplayName);
|
|
}
|
|
$jobs[] = [
|
|
'id' => $job->id,
|
|
'displayName' => $displayName,
|
|
'status' => $job->attempts == 0 ? 'Pending' : 'Processing',
|
|
'createdAt' => $job->created_at
|
|
];
|
|
|
|
}
|
|
}
|
|
|
|
return view('filament.job-queue-notifications', [
|
|
'jobs' => $jobs
|
|
]);
|
|
}
|
|
|
|
}
|