PHP code example of borah / knowledge-base-laravel

1. Go to this page and download the library: Download borah/knowledge-base-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

borah / knowledge-base-laravel example snippets


return [
    'connection' => [
        'host' => env('KNOWLEDGE_BASE_HOST', 'http://localhost:8100'),
    ],
    'models' => [
        'knowledge_base_id' => \Borah\KnowledgeBase\Models\KnowledgeBaseId::class,
    ],
];




namespace App\Models;

use Borah\KnowledgeBase\Contracts\Embeddable;
use Borah\KnowledgeBase\DTO\KnowledgeEmbeddingText;
use Borah\KnowledgeBase\Traits\BelongsToKnowledgeBase;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Post extends Model implements Embeddable
{
    use HasFactory;
    use BelongsToKnowledgeBase;

    public function getEmbeddingsTexts(): KnowledgeEmbeddingText|array
    {
        return [
            new KnowledgeEmbeddingText(
                text: $this->content,
                entity: class_basename($this),
            ),
        ];
    }
}
bash
php artisan vendor:publish --tag="knowledge-base-laravel-migrations"
bash
php artisan vendor:publish --tag="knowledge-base-laravel-config"