Skip to content

sebastiankennedy/laravel-like

Repository files navigation

laravel-like

User like feature for laravel application.

Build Status Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Code Coverage Total Downloads License

References

Requires

  • PHP >= 7.3
  • Laravel >= ^6.0

Installing

$ composer require sebastian-kennedy/laravel-like -vvv

Configuration

$ php artisan vendor:publish --provider="SebastianKennedy\\LaravelLike\\LikeServiceProvider" --tag=config

Migrations

$ php artisan vendor:publish --provider="SebastianKennedy\\LaravelLike\\LikeServiceProvider" --tag=migrations

Usage

BeLikedBehavior.php

<?php

namespace SebastianKennedy\LaravelLike\Tests\Models;

use Illuminate\Database\Eloquent\Model;
use SebastianKennedy\LaravelLike\Behaviors\CanBeLikedBehavior;

class Book extends Model
{
    use CanBeLikedBehavior;

    protected $fillable = ['title'];
}

ToLikeBehavior.php

<?php

namespace SebastianKennedy\LaravelLike\Tests\Models;

use Illuminate\Database\Eloquent\Model;
use SebastianKennedy\LaravelLike\Behaviors\CanLikeBehavior;

class User extends Model
{
    use CanLikeBehavior;
    protected $fillable = ['name'];
}

API

<?php

$user = User::first();
$book = Book::first();

$user-like($book);
$user->unlike($book);
$user->toggleLike($book);
$user->hasLiked($book);
$user->likes();

$book->isLikedBy($user);
$book->likes();
$book->likers();

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-12 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

About

User like feature for laravel application.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages