Skip to content
This repository was archived by the owner on Jul 31, 2018. It is now read-only.

Commit 1aacec0

Browse files
committed
update README
1 parent 04550af commit 1aacec0

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

README.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Algolia Search for Laravel
44
This php package integrate the Algolia Search API to your favorite Laravel Eloquent ORM. It's based on the [algoliasearch-client-php](https://github.com/algolia/algoliasearch-client-php) package. Php 5.4+ is supported.
55

66
[![Build Status](https://img.shields.io/travis/algolia/algoliasearch-laravel/master.svg?style=flat)](https://travis-ci.org/algolia/algoliasearch-laravel)
7-
[![ActiveRecord](https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat)](https://github.com/algolia/algoliasearch-laravel)
87
[![Latest Version](https://img.shields.io/github/release/algolia/algoliasearch-laravel.svg?style=flat)](https://github.com/algolia/algoliasearch-laravel/releases)
98
[![License](https://img.shields.io/packagist/l/algolia/algoliasearch-laravel.svg?style=flat)](https://packagist.org/packages/algolia/algoliasearch-laravel)
109

@@ -36,7 +35,7 @@ Add `algolia/algoliasearch-laravel` to your `composer.json` file:
3635
Add the service provider to ```config/app.php``` in the `providers` array.
3736

3837
```php
39-
'Algolia\AlgoliasearchLaravel\AlgoliaServiceProvider'
38+
'AlgoliaSearch\Laravel\AlgoliaServiceProvider'
4039
```
4140

4241
Configuration
@@ -95,10 +94,17 @@ class Contact extends \Illuminate\Database\Eloquent\Model
9594

9695
public $algolia_settings = [
9796
'attributesToIndex => ['id', 'name'],
98-
'customRanking => ['desc(popularity)', 'asc('name')]
97+
'customRanking => ['desc(popularity)'], 'asc(name)]'
9998
]
10099
}
101100
```
101+
102+
You can then do a save the settings to algolia using the setSetting method
103+
104+
```php
105+
Contact::setSettings();
106+
```
107+
102108
#### Frontend Search (realtime experience)
103109

104110
Traditional search implementations tend to have search logic and functionality on the backend. This made sense when the search experience consisted of a user entering a search query, executing that search, and then being redirected to a search result page.
@@ -120,7 +126,7 @@ index.search('something', function(success, hits) {
120126
You could also use `search` but it's not recommended. This method will search on Algolia
121127

122128
```php
123-
Contact::search("jon doe")
129+
Contact::search("jon doe");
124130
```
125131

126132
Options
@@ -135,14 +141,14 @@ You can disable auto-indexing and auto-removing setting the following options:
135141
```php
136142
class Contact extends \Illuminate\Database\Eloquent\Model
137143
{
138-
use AlgoliaEloquentTrait;
144+
use AlgoliaEloquentTrait;
139145

140-
public $auto_index = false;
141-
public $auto_delete = false;
146+
public $auto_index = false;
147+
public $auto_delete = false;
142148
}
143149
```
144150

145-
You can temporary disable auto-indexing using the <code>without_auto_index</code> scope. This is often used for performance reason.
151+
You can temporary disable auto-indexing. This is often used for performance reason.
146152

147153
```php
148154
Contact::$auto_index = false;
@@ -151,7 +157,7 @@ Contact.clearIndices();
151157
for ($i = 0; $i < 10000; $i++)
152158
$contact = Contact::firstOrCreate(['name' => 'Jean']);
153159

154-
Contact::reindex()! # will use batch operations
160+
Contact::reindex() # will use batch operations
155161
```
156162

157163
#### Custom index name
@@ -189,7 +195,7 @@ class Contact extends \Illuminate\Database\Eloquent\Model
189195
{
190196
use AlgoliaEloquentTrait;
191197

192-
public $object_id_key = 'new key';
198+
public $object_id_key = 'new_key';
193199
}
194200
```
195201

@@ -204,10 +210,11 @@ class Contact extends \Illuminate\Database\Eloquent\Model
204210

205211
public function indexOnly($index_name)
206212
{
207-
if ($index_name == "contact_all")
208-
return $this->isActive == 1
209-
210-
return 1;
213+
if ($condition) {
214+
return 1;
215+
}
216+
217+
return 0;
211218
}
212219
}
213220
```
@@ -220,7 +227,7 @@ Indexing
220227
You can trigger indexing using the <code>pushToindex</code> instance method.
221228

222229
```php
223-
$c = Contact::firstOrCreate!(['name' => 'Jean']);
230+
$c = Contact::firstOrCreate(['name' => 'Jean']);
224231
$c->pushToindex();
225232
```
226233

@@ -229,7 +236,7 @@ $c->pushToindex();
229236
And trigger index removing using the <code>removeFromIndex</code> instance method.
230237

231238
```php
232-
$c = Contact::firstOrCreate!(['name' => 'Jean']);
239+
$c = Contact::firstOrCreate(['name' => 'Jean']);
233240
$c->removeFromindex();
234241
```
235242
#### Reindexing
@@ -265,9 +272,9 @@ class Contact extends \Illuminate\Database\Eloquent\Model
265272
use AlgoliaEloquentTrait;
266273

267274
public $algolia_settings = [
268-
'attributesToIndex' => ['id', 'name'],
269-
'customRanking' => ['desc(popularity)', 'asc(name)'],
270-
'slaves' => ['contacts_desc']
275+
'attributesToIndex' => ['id', 'name'],
276+
'customRanking' => ['desc(popularity)', 'asc(name)'],
277+
'slaves' => ['contacts_desc']
271278
];
272279

273280
public $slaves_settings = [

0 commit comments

Comments
 (0)