PHPackages                             catzilla/scout-noindex - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. catzilla/scout-noindex

ActiveLibrary

catzilla/scout-noindex
======================

This package provides a simple way to prevent indexing certain model fields when you using Laravel Scout.

v0.1.0(7y ago)1167MITPHPPHP &gt;=7.0

Since Sep 3Pushed 7y ago2 watchersCompare

[ Source](https://github.com/Catzilla/scout-noindex)[ Packagist](https://packagist.org/packages/catzilla/scout-noindex)[ RSS](/packages/catzilla-scout-noindex/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

scout-noindex
=============

[](#scout-noindex)

[![GitHub license](https://camo.githubusercontent.com/273ffe80be9979d3644a43e3d498c440604b87b3a0dd858ecf04812fd25d1ab2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4361747a696c6c612f73636f75742d6e6f696e6465782e737667)](https://github.com/Catzilla/scout-noindex/blob/master/LICENSE)

This package provides a simple way to prevent indexing certain model fields when you using [Laravel Scout](https://github.com/laravel/scout).

By default, every time you save Eloquent model, `saved` event will fire. As result, `MakeSearchable` job will dispatch even if nothing changed in model (see Scout issue [\#285](https://github.com/laravel/scout/issues/285)).

For example:

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

Another case, when you only want to search model by some fields, for example by `name` and `login`. You change something another, but `MakeSearchable` job will dispatch:

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

This package helps solve this issues in easy way.

Installing
----------

[](#installing)

You can install this package via Composer:

```
composer require catzilla/scout-noindex

```

Usage
-----

[](#usage)

In your model file simply replace `Searchable` trait with provided by this package.

Optional, you can use `$index` and `$noindex` properties to include or exclude fields from search syncing.

```
