You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user