PHP code example of ossycodes / laravel-scout-upstash-search

1. Go to this page and download the library: Download ossycodes/laravel-scout-upstash-search 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/ */

    

ossycodes / laravel-scout-upstash-search example snippets


use Laravel\Scout\Searchable;

class Post extends Model
{
    use Searchable;

    protected $searchableAs = 'posts';

    public function toSearchableArray()
    {
        return [
            'title' => $this->title,
            'body' => $this->body,
        ];
    }
}

'driver' => env('SCOUT_DRIVER', 'upstash'),

// Search
$results = Post::search('laravel')->get();

// Paginate
$results = Post::search('laravel')->paginate(15);

// Import all records
php artisan scout:upstash-import "App\Models\Post"
bash
php artisan vendor:publish --provider="LaravelUpstashSearch\Scout\UpstashSearchServiceProvider" --tag="config"