<?php

namespace App\Http\Main\Engineers\Donor;

use App\Models\Donor;
use Livewire\Component;

class Index extends Component
{


    public $queryString = ['q'];
    public $q;

    public function mount()
    {
    }


    public function render()
    {
        if ($this->q == '') {
            $donors = Donor::all();
        } else {
            $donors = Donor::orWhere('pcb_no', 'LIKE', '%' . $this->q . '%')->orWhere('model_no', 'LIKE', '%' . $this->q . '%')->get();
        }
        $donor=$donors->first()->id;
        redirect(url('/engineers/donors/'.$donor));
        return view('main.engineers.donor.index', [
            'donors' => $donors
        ])->layout('layouts.app-engineers');
    }
}
