File: /var/www/admin.fixgini.com/app/Livewire/Task/Index.php
<?php
namespace App\Livewire\Task;
use Livewire\Component;
use App\Models\BookingForm;
use Livewire\WithPagination;
class Index extends Component
{
use WithPagination;
public $perPage = 10;
public $search = ''; // Add this property to store the search term
public function changeTaskStatus($taskId, $newStatus)
{
// Find the task by its ID
$task = BookingForm::find($taskId);
if ($task) {
// Update the task status to the selected new status
$task->status = $newStatus;
// Save the updated status
$task->save();
// Optionally, you can emit an event or flash a message
session()->flash('success', 'Task status updated successfully!');
return $this->redirect(request()->header('Referer'), navigate: true);
}
}
public function render()
{
$tasks = BookingForm::whereHas('gig', function ($query) {
$query->where('title', 'like', '%' . $this->search . '%');
})
->orWhereHas('customer', function ($query) {
$query->where('name', 'like', '%' . $this->search . '%');
})
->latest()
->paginate($this->perPage);
return view('livewire.task.index', compact('tasks'));
}
}