1. Go to this page and download the library: Download snowbuilds/laravel-mirror 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/ */
snowbuilds / laravel-mirror example snippets
use SnowBuilds\Mirror\Concerns\Recommendations;
use SnowBuilds\Mirror\Mirror;
class Post extends Model
{
use Recommendations;
public function registerRecommendations(): void
{
$this->registerStrategy(Post::class)
->levenshtein('title');
}
}
public function registerRecommendations(): void
{
$this->registerStrategy(Post::class)
->levenshtein('title', 2)
->euclidean('tags', 1);
}
class User extends Model
{
use Recommendations;
public function registerRecommendations(): void
{
$this->registerStrategy(Post::class)
->levenshtein('biography', 'title', 1) // compare biography to post title
->euclidean('communities', 'tags', 3); // compare communities to post tags
}
}
class User extends Model
{
public function registerRecommendations(): void
{
$this->registerStrategy(Post::class)
->using(function (User $a, Post $b) {
return Algorithm::levenshtein($a->name, $b->name);
});
}
}