GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
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'));
    }
}