<?php

namespace App\Models;

class EventClientModel extends TenantModel
{
    protected $table            = 'event_clients';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'object';
    protected $useTimestamps    = true;

    protected $allowedFields = [
        'company_name',
        'contact_name',
        'phone',
        'email',
        'catering_preferences',
    ];

    protected $validationRules = [
        'company_name' => 'required|max_length[150]',
        'email'        => 'permit_empty|valid_email',
    ];

    public function search(string $term)
    {
        return $this->groupStart()
            ->like('company_name', $term)
            ->orLike('contact_name', $term)
            ->orLike('phone', $term)
            ->groupEnd();
    }
}
