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/ */
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),
),
];
}
}