1. Go to this page and download the library: Download tag1/scolta-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/ */
tag1 / scolta-laravel example snippets
// app/Models/Recipe.php
use Tag1\Scolta\Export\ContentItem;
use Tag1\ScoltaLaravel\Searchable;
class Recipe extends Model
{
use Searchable;
public function toSearchableContent(): ContentItem
{
return new ContentItem(
id: "recipe-{$this->id}",
title: $this->name,
bodyHtml: "<p>{$this->description}</p>"
. "<h2>Ingredients</h2><ul>"
. implode('', array_map(fn($i) => "<li>{$i}</li>", $this->ingredients))
. "</ul><p>Tags: {$this->tags}, {$this->regional_synonyms}</p>",
url: "/recipes/{$this->slug}",
date: $this->updated_at->format('Y-m-d'),
siteName: config('scolta.site_name', config('app.name')),
);
}
public function scopeSearchable($query)
{
return $query->where('published', true);
}
}
// app/Listeners/EnrichScoltaPrompt.php
use Tag1\ScoltaLaravel\Events\PromptEnrichEvent;
class EnrichScoltaPrompt
{
public function handle(PromptEnrichEvent $event): void
{
if ($event->promptName === 'summarize') {
$event->resolvedPrompt .= "\n\nFocus on dietary information and cuisine type.";
}
}
}
use Tag1\Scolta\Export\ContentItem;
use Tag1\ScoltaLaravel\Searchable;
class Article extends Model
{
use Searchable;
public function toSearchableContent(): ContentItem
{
return new ContentItem(
id: "article-{$this->id}",
title: $this->title,
bodyHtml: $this->body,
url: "/articles/{$this->slug}",
date: $this->updated_at->format('Y-m-d'),
siteName: config('scolta.site_name', config('app.name')),
);
}
// Optional: filter which records to index
public function scopeSearchable($query)
{
return $query->where('published', true);
}
}