Skip to content

Commit

Permalink
Merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Dec 23, 2020
2 parents 7a4a9ec + b1ddfad commit 08d87b6
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
phpunit:
strategy:
matrix:
php_version: [7.2, 7.3, 7.4]
php_version: [7.4]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 5 additions & 0 deletions config/like.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

return [
/**
* Use uuid as primary key.
*/
'uuids' => false,

/*
* User tables foreign key name.
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Like.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Overtrue\LaravelLike\Events\Liked;
use Overtrue\LaravelLike\Events\Unliked;

class Like extends Model
{
protected $guarded = [];

protected $dispatchesEvents = [
'created' => Liked::class,
'deleted' => Unliked::class,
Expand All @@ -31,6 +34,11 @@ protected static function boot()
self::saving(function ($like) {
$userForeignKey = \config('like.user_foreign_key');
$like->{$userForeignKey} = $like->{$userForeignKey} ?: auth()->id();


if (\config('like.uuids')) {
$like->{$like->getKeyName()} = $like->{$like->getKeyName()} ?: (string) Str::orderedUuid();
}
});
}

Expand Down
11 changes: 0 additions & 11 deletions tests/Book.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests;

use Illuminate\Database\Eloquent\Model;
use Overtrue\LaravelLike\Traits\Likeable;

/**
* Class Book.
*/
class Book extends Model
{
use Likeable;
Expand Down
11 changes: 0 additions & 11 deletions tests/FeatureTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests;

use Illuminate\Database\Eloquent\Relations\Relation;
Expand All @@ -16,9 +8,6 @@
use Overtrue\LaravelLike\Events\Unliked;
use Overtrue\LaravelLike\Like;

/**
* Class FeatureTest.
*/
class FeatureTest extends TestCase
{
public function setUp(): void
Expand Down
11 changes: 0 additions & 11 deletions tests/Post.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests;

use Illuminate\Database\Eloquent\Model;
use Overtrue\LaravelLike\Traits\Likeable;

/**
* Class Post.
*/
class Post extends Model
{
use Likeable;
Expand Down
8 changes: 0 additions & 8 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests;

use Overtrue\LaravelLike\LikeServiceProvider;
Expand Down
11 changes: 0 additions & 11 deletions tests/User.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests;

use Illuminate\Database\Eloquent\Model;
use Overtrue\LaravelLike\Traits\Likeable;
use Overtrue\LaravelLike\Traits\Liker;

/**
* Class User.
*/
class User extends Model
{
use Liker;
Expand Down
8 changes: 0 additions & 8 deletions tests/migrations/2018_12_14_095815_create_books_table.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
8 changes: 0 additions & 8 deletions tests/migrations/2018_12_14_095815_create_posts_table.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
8 changes: 0 additions & 8 deletions tests/migrations/2018_12_14_095815_create_users_table.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

/*
* This file is part of the overtrue/laravel-like.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down

0 comments on commit 08d87b6

Please sign in to comment.