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) {
// Handle the 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();
namespace Acme\MyRecombee;
use Amranidev\Laracombee\AbstractRecombee;
use Recombee\RecommApi\Requests\Request;
class MyRecombee extends AbstractRecombee
{
public function __construct()
{
parent::__construct(
config('laracombee.database'),
config('laracombee.token'),
[
'timeout' => config('laracombee.timeout'),
'region' => config('laracombee.region'),
'protocol' => config('laracombee.protocol'),
]
);
}
public function send(Request $request)
{
return $this->client->send($request);
}
}