aw-studio / laravel-indexer

0 stars 0 forks source link

Design changes #2

Closed cbl closed 3 years ago

cbl commented 3 years ago

This pr adds some design changes.

Removed Indexer

The name of the indexer class suggests that it is responsible for indexing pages. However, it performs a search on pages. For the search no class is necessary, because the eloquent query builder already offers a flexible api for filtering search results.

Added Laravel Scout

Laravel Scout's trait Searchable is added to the model that stores the web page content. This way algolia, the laravel-scout-mysql-driver or other drivers may be added to provide the search results.

Renamed Model

The model was renamed from PageIndexRecord to WebPage as it increases readability. The model may be used like this:

$results = WebPage::search($request->search)->take(10)->get();

Added Model and table name to config

The model class and database table name were added to the config to make the customizable.

Added .gitignore

The .gitignore was added.