TenantAtlas/app/Livewire/BulkOperationProgress.php
2025-12-25 01:20:04 +01:00

48 lines
970 B
PHP

<?php
namespace App\Livewire;
use App\Models\BulkOperationRun;
use App\Models\Tenant;
use Livewire\Attributes\Computed;
use Livewire\Component;
class BulkOperationProgress extends Component
{
public $runs;
public function mount()
{
$this->loadRuns();
}
#[Computed]
public function activeRuns()
{
return $this->runs;
}
public function loadRuns()
{
try {
$tenant = Tenant::current();
} catch (\RuntimeException $e) {
$this->runs = collect();
return;
}
$this->runs = BulkOperationRun::query()
->where('tenant_id', $tenant->id)
->where('user_id', auth()->id())
->whereIn('status', ['pending', 'running'])
->orderByDesc('created_at')
->get();
}
public function render(): \Illuminate\Contracts\View\View
{
return view('livewire.bulk-operation-progress');
}
}