PHP code example of christiankuri / laravel-favorite

1. Go to this page and download the library: Download christiankuri/laravel-favorite 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/ */

    

christiankuri / laravel-favorite example snippets


'providers' => [
    // ...
    ChristianKuri\LaravelFavorite\FavoriteServiceProvider::class,
];

use ChristianKuri\LaravelFavorite\Traits\Favoriteability;

class User extends Authenticatable
{
	use Favoriteability;
}

use ChristianKuri\LaravelFavorite\Traits\Favoriteable;

class Post extends Model
{
    use Favoriteable;
}
shell
php artisan vendor:publish --provider="ChristianKuri\LaravelFavorite\FavoriteServiceProvider"
shell
php artisan migrate
 php
$user = Auth::user();
$user->favorite(Post::class); // returns a collection with the Posts the User marked as favorite