PHP code example of mamadali / yii2-favorites

1. Go to this page and download the library: Download mamadali/yii2-favorites 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/ */

    

mamadali / yii2-favorites example snippets


    'components' => [
        ...
        'favorites' => [
            'class' => 'mamadali\favorites\Favorite',
        ],
        ...
    ];

   Yii::$app->favorites->add(Product::class, $product->id);

   Yii::$app->favorites->remove(Product::class, $product->id);

   Yii::$app->favorites->has(Product::class, $product->id);

   Yii::$app->favorites->getAll(Product::class);

   Yii::$app->favorites->getCount(Product::class);

   Yii::$app->favorites->getDataProvider(Product::class);

php yii migrate/up --migrationPath=@vendor/mamadali/yii2-favorites/migrations