<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Titulo extends Model
{
    protected $table = 'sige.titulos';
    protected $fillable = ['id', 'numero_titulo', 'gleba_id'];

    public function search($filter = null)
    {
        $results = $this->where(function ($query) use ($filter){
            if($filter){
                $query->where('numero_titulo', "{$filter}")
                ->orWhere('lote_id', "{$filter}")
                ->orWhere('gleba_id', "{$filter}");
            }
        })->paginate();
        return $results;
    }

    

    // public function lotes()
    // {
    //     return $this->belongsTo(Titulo::class);
    // }

    // public function gleba()
    // {
    //     return $this->hasOne(Gleba::class,'id');
    // } 
    
}
