<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\Machine;

class Machines extends Component
{
    public $machines, $search = '', $data, $Title;

    public $updateMode = false;
    public $imputActive = false;

    public function render()
    {
        $this->data = ($this->search)
            ? Machine::where('id', 'like', '%'.$this->search.'%')
                ->orWhere('model', 'like', '%'.$this->search.'%')
                ->orWhere('address', 'like', '%'.$this->search.'%')
                ->get()
            : Machine::orderBy('id', 'DESC')->get();
        return view('livewire.machines', ['data' => $this->data]);
    }
}
