PHP code example of amranidev / laracombee

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


'user' => \App\Models\User::class,
'item' => \App\Models\Book::class,



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);
    }
}
bash
php artisan vendor:publish --tag=laracombee-config
bash
php artisan laracombee:migrate user
php artisan laracombee:migrate item
bash
php artisan laracombee:rollback user
php artisan laracombee:rollback item
bash
php artisan laracombee:seed user
php artisan laracombee:seed item
bash
php artisan laracombee:seed user --chunk=250
bash
php artisan laracombee:add email:string age:int --to=user
php artisan laracombee:drop email age --from=user
bash
php artisan laracombee:reset
bash
php artisan laracombee:new CustomLaracombee
bash
php artisan laracombee:new ReportingLaracombee