-
Notifications
You must be signed in to change notification settings - Fork 3
2. Configuration
By default, all the model properties or columns will be created as string types in Recombee. If you would like to customize it, you may override the toRecommendableProperties method on the model:
Note: The ID property for users and items is predefined as a string type by Recombee, hence you won't be able to customize its name or type or use any of the reserved names (
id,userId,itemId) for any other property.
class User extends Authenticatable
{
use Recommendable;
...
public function toRecommendableProperties()
{
return [
'name' => 'string',
'age' => 'int',
'active' => 'boolean',
];
}Please visit Recombee's API Reference for all valid property types.
By default, the entire toArray form of a given model will be persisted to Recombee. If you would like to customize the data that is saved to the database, you may override the toRecommendableArray method on the model:
class User extends Authenticatable
{
use Recommendable;
...
public function toRecommendableArray()
{
return [
'id' => $this->id,
'name' => $this->name,
'age' => $this->age,
'active' => $this->active,
];
}If you would like to modify the query that is used to retrieve all of your models for batch importing, you may define a makeAllRecommendableUsing method on your model. This is a great place to add any eager relationship loading that may be necessary before importing your models:
use Illuminate\Database\Eloquent\Builder;
class User extends Authenticatable
{
use Recommendable;
...
protected function makeAllRecommendableUsing(Builder $query)
{
return $query->with('country');
}