<?php
/**
 * Application Service Provider
 *
 * @package ZenoChatbot\ServiceProvider
 */

namespace ZenoChatbot\ServiceProvider;

use ZenoChatbot\Framework\Foundation\ServiceProvider;
use ZenoChatbot\Framework\Database\QueryBuilder;

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

/**
 * Simple application service provider
 * Only handles QueryBuilder binding as 'db'
 */
class AppServiceProvider extends ServiceProvider
{
    /**
     * Register services
     */
    public function register()
    {
        // Register QueryBuilder as 'db' for raw queries like $app->db()->table('table_name')
        $this->app->singleton('db', function () {
            return new QueryBuilder();
        });

        // Register LLM Service
        $this->app->singleton(\ZenoChatbot\Services\LLMService::class, function () {
            return new \ZenoChatbot\Services\LLMService();
        });

    }

    /**
     * Boot services
     */
    public function boot()
    {
        // Set QueryBuilder in Model for $app->db() usage
        \ZenoChatbot\Framework\Database\Model::setConnection($this->app->make('db'));

        // Set App facade instance
        \ZenoChatbot\App::setInstance($this->app);
    }
}
