Skip to content

Repository files navigation

datalumo/laravel

Laravel package for Datalumo. Sync Eloquent models, search them, and embed widgets.

Built on datalumo/php.

Install

composer require datalumo/laravel
php artisan vendor:publish --tag=datalumo-config

Requires PHP 8.2+ and Laravel 11, 12, or 13. Laravel 13 requires PHP 8.3+.

Configure

DATALUMO_BASE_URL=https://datalumo.app
DATALUMO_ORG=your-org-public-id
DATALUMO_TOKEN=your-api-token
DATALUMO_SOURCE=docs
DATALUMO_SEARCH_WIDGET={org-public-id}/{search-widget-id}
DATALUMO_CHAT_WIDGET={org-public-id}/{chat-widget-id}

DATALUMO_ORG is the organisation public id, not the slug.

Search and chat are separate widgets in Datalumo (different types). Set both if you use both embeds. You can still pass a widget prop to a component to override the default.

Optional check:

php artisan datalumo:install

Make a model searchable

use Datalumo\Laravel\Searchable;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use Searchable;

    public function toDatalumoArray(): array
    {
        return [
            'external_id' => (string) $this->getKey(),
            'name' => $this->title,
            'content' => $this->body,
            'content_mime' => 'text/markdown',
            'source_url' => route('articles.show', $this),
        ];
    }
}

Models sync on save and delete (queued by default).

Import existing rows:

php artisan datalumo:import "App\Models\Article"

Search

Server-side search uses DATALUMO_SEARCH_WIDGET:

$articles = Article::datalumoSearch('how to deploy')->get();

Embeds

<x-datalumo::search />
<x-datalumo::chat />

{{-- Override when needed --}}
<x-datalumo::search widget="org/other-search-widget" />
<x-datalumo::chat widget="org/other-chat-widget" />

@stack('datalumo-scripts')

Next steps

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages