Generating Bridge Classes
To get started, create a bridge with the artisan make:bridge
command. Bridges usually live in the App\Bridges
directory. however, this can be changed through elasticbridge.namespace
config.
bash
php artisan make:bridge HotelRoom
Naming Conventions
Bridges generated by the make:bridge command will be placed in the app/Bridges
directory. Here's a basic bridge class and some key conventions:
php
<?php
namespace App\Bridges;
use Lacasera\ElasticBridge\ElasticBridge;
class HotelRoom extends ElasticBridge
{
}
Index Names
The example above is a bridge class for HotelRoom
bridge. By convention, just like an eloquent model, the snake case
, plural
name of the class will be used as the index
name unless another name is explicitly specified.
If your bridge's corresponding elastic search index does not fit this convention, you may manually specify the index name by defining an index
property on the model:
php
<?php
namespace App\Bridges;
use Lacasera\ElasticBridge\ElasticBridge;
class HotelRoom extends ElasticBridge
{
protected $index = 'hotel-rooms';
}