You've already forked Atomcms-edit
46 lines
1.3 KiB
PHP
Executable File
46 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Miscellaneous\WebsiteMaintenanceTask;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\Concerns\InteractsWithActions;
|
|
use Filament\Actions\Contracts\HasActions;
|
|
use Filament\Forms\Concerns\InteractsWithForms;
|
|
use Filament\Forms\Contracts\HasForms;
|
|
use Livewire\Component;
|
|
|
|
class MaintenanceTaskStatus extends Component implements HasActions, HasForms
|
|
{
|
|
use InteractsWithActions;
|
|
use InteractsWithForms;
|
|
|
|
public int $taskId;
|
|
|
|
public bool $completed;
|
|
|
|
public function mount(int $taskId, bool $completed): void
|
|
{
|
|
$this->taskId = $taskId;
|
|
$this->completed = $completed;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.maintenance-task-status');
|
|
}
|
|
|
|
public function toggleStatusAction(): Action
|
|
{
|
|
return Action::make('toggleStatus')
|
|
->label($this->completed ? __('Mark as In Progress') : __('Mark as Completed'))
|
|
->icon($this->completed ? 'heroicon-o-clock' : 'heroicon-o-check-circle')
|
|
->color($this->completed ? 'warning' : 'success')
|
|
->action(function () {
|
|
$task = WebsiteMaintenanceTask::findOrFail($this->taskId);
|
|
$task->update(['completed' => ! $this->completed]);
|
|
$this->completed = ! $this->completed;
|
|
});
|
|
}
|
|
}
|