PHP code example of catzilla / scout-noindex

1. Go to this page and download the library: Download catzilla/scout-noindex 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/ */

    

catzilla / scout-noindex example snippets


// Retrieving first entry from database
$model = User::first();
// Nothing changed here, saving model
$model->save();
// Database query not performed, but MakeSearchable job dispatched

// Retrieving first entry from database
$model = User::first();
// Changing email (NOT name or login)
$model->email = '[email protected]';
// Saving model
$model->save();
// email field updated, and MakeSearchable job dispatched even if we don't need to search by email



namespace App;

use Illuminate\Database\Eloquent\Model;
use Catzilla\ScoutNoindex\Searchable;

class User extends Model
{
    use Searchable;
    
    /**
     * Array of fields to search.
     * When this property present in model, only this fields will be searchable
     *
     * @var array
     */
    protected $index = [
        'name',
        'login'
    ];
    
    /**
     * Array of fields to exclude from syncing.
     * When this property present in model, any changes in this fields will not trigger search syncing.
     *
     * @var array
     */
    protected $noindex = [
        'email',
        'updated_at'
    ];
}