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/ */
amranidev / laracombee example snippets
// Service provider.
Amranidev\Laracombee\Providers\LaracombeeServiceProvider::class,
// Alias.
'Laracombee' => Amranidev\Laracombee\Facades\LaracombeeFacade::class,
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
public static $laracombee = ['name' => 'string', 'age' => 'int'];
}
/*
|--------------------------------------------------------------------------
| Default models for user and item.
|--------------------------------------------------------------------------
|
| Here where you can define the default class for user and item.
|
*/
'user' => app(\App\User::class),
'item' => app(\App\Book::class),
// Add a user to recombee.
$user = User::findOrFail($id);
$addUser = Laracombee::addUser($user);
Laracombee::send($addUser)->then(function () {
// Success.
})->otherWise(function ($error) {
// Handle Exeption.
})->wait();
// Get users from your db.
$user1 = User::findOrFail(1);
$user2 = User::findOrFail(2);
$user3 = User::findOrFail(3);
// Prepare request.
$users = Laracombee::addUsers([$user1, $user2, $user3]);
// Send request as bulk.
Laracombee::batch($users);
$user = User::findOrFail($id);
// Prepare the request for recombee server, we need 10 recommended items for a given user.
$recommendations = Laracombee::recommendTo($user, 1O)->wait();