1. Go to this page and download the library: Download amranidev/laracombee library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
public static $laracombee = [
'name' => 'string',
'age' => 'int',
];
}
use App\Models\User;
use Laracombee;
$user = User::findOrFail($id);
$request = Laracombee::addUser($user);
Laracombee::send($request)
->then(function () {
// Success.
})
->otherwise(function ($error) {
// $error is the original exception.
report($error);
})
->wait();
use App\Models\User;
use Laracombee;
$users = User::findMany([1, 2, 3])->all();
$batch = Laracombee::addUsers($users);
Laracombee::batch($batch)->wait();
use App\Models\User;
use Laracombee;
$user = User::findOrFail($id);
$recommendations = Laracombee::recommendTo($user, 10)->wait();
$itemIds = collect($recommendations['recomms'])
->pluck('id')
->all();
use Amranidev\Laracombee\Laracombee;
$client = app(Laracombee::class);
use Amranidev\Laracombee\Laracombee;
use Recombee\RecommApi\Client;
$configuration = config('laracombee');
$sdk = new Client($configuration['database'], $configuration['token'], [
'region' => $configuration['region'],
'protocol' => $configuration['protocol'],
]);
$client = new Laracombee($sdk, configuration: $configuration);
use Amranidev\Laracombee\ModelMapper;
class CatalogMapper extends ModelMapper
{
public function values(object $model): array
{
$values = parent::values($model);
if (isset($values['name'])) {
$values['name'] = trim($values['name']);
}
return $values;
}
}
$this->app->bind(ModelMapper::class, CatalogMapper::class);