<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Agendamento extends Model
{
    protected $table = 'agendamento.agendamentos';
    protected $fillable = ['nome', 'cpf', 'telefone','servico', 'data'];

    public function search($filter = null)
    {
        $results = $this->where(function ($query) use ($filter){
            if($filter){
                $query->where('nome', 'LIKE', "%{$filter}%");
            }
        })//->toSql();
        ->paginate();
        return $results;
    }
}
