From bafa5205a2f59c7fec470f39ebd52c1931717292 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Tue, 9 Mar 2021 20:20:10 +0100 Subject: [PATCH] v4 (#305) * New major version: v4 (PHP8+) (#303) * only allow php ^8.0 * only run tests on PHP 8 * update gitignore * convert phpdoc types to actual union types where appropriate; add several return types * use laravel-package-tools package * implement spatie/laravel-package-tools * add Collection to union return type for findOrCreate() * Fix styling * update requirements doc with PHP >=8 * update changelog * update doc link * nitpicks * nitpicks * wip * wip * wip * Fix styling * wip * wip * wip Co-authored-by: Patrick Co-authored-by: freekmurze --- .github/workflows/deploy-docs.yml | 19 --- .github/workflows/run-tests.yml | 12 +- .gitignore | 2 + CHANGELOG.md | 4 + UPGRADING.md | 4 + composer.json | 5 +- config/tags.php | 2 +- .../migrations/create_tag_tables.php.stub | 9 +- docs/_index.md | 2 +- docs/advanced-usage/adding-translations.md | 2 +- docs/advanced-usage/using-types.md | 2 +- .../using-your-own-tag-model.md | 5 +- docs/basic-usage/using-tags.md | 9 +- docs/installation-and-setup.md | 3 - docs/introduction.md | 4 +- docs/postcardware.md | 4 +- docs/requirements.md | 2 +- src/HasSlug.php | 8 +- src/HasTags.php | 143 ++++++------------ src/Tag.php | 24 +-- src/TagsServiceProvider.php | 23 +-- tests/HasTagsScopesTest.php | 2 +- tests/HasTagsTest.php | 7 +- tests/HasTagsTranslatedTest.php | 2 +- tests/TagTest.php | 4 +- tests/{ => TestClasses}/TestAnotherModel.php | 2 +- tests/{ => TestClasses}/TestModel.php | 2 +- 27 files changed, 117 insertions(+), 190 deletions(-) delete mode 100644 .github/workflows/deploy-docs.yml rename tests/{ => TestClasses}/TestAnotherModel.php (85%) rename tests/{ => TestClasses}/TestModel.php (84%) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml deleted file mode 100644 index dfdf306..0000000 --- a/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: deploy-docs - -on: - push: - paths: - - 'docs/**' - -jobs: - deploy: - - runs-on: ubuntu-latest - - name: Deploy docs - - steps: - - name: Netlify deploy - uses: wei/curl@v1 - with: - args: -X POST -d {} ${{ secrets.NETLIFY_DEPLOY_URL }}?trigger_title=laravel-tags diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e974c7e..0b5a56c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,15 +3,13 @@ name: run-tests on: push: pull_request: - schedule: - - cron: '0 0 * * *' jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - php: [8.0,7.4] + php: [8.0] laravel: [8.*] dependency-version: [prefer-lowest, prefer-stable] os: [ubuntu-latest] @@ -33,13 +31,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + uses: actions/checkout@v2 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.gitignore b/.gitignore index 69fb660..f2f31e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +.idea build composer.lock vendor .env .php_cs.cache +.phpunit.result.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index da1e1c9..00cd283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-tags` will be documented in this file +## 4.0.0 - 2021-03-09 + +- drop support for all PHP versions below 8.0 + ## 3.1.0 - 2021-03-01 -add `tag_model` config variable (#301) diff --git a/UPGRADING.md b/UPGRADING.md index 0301307..b19a9ce 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,3 +1,7 @@ +# From v3 to v4 + +There were no changes to the API, so you don't need to modify anything in your project code. + # From v2 to v3 There were no changes to the API, so you don't need to modify anything in your project code. diff --git a/composer.json b/composer.json index 8dfe58a..12f403a 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,16 @@ } ], "require": { - "php": "^7.4|^8.0", + "php": "^8.0", "laravel/framework": "^8.0", "spatie/eloquent-sortable": "^3.5", + "spatie/laravel-package-tools": "^1.4", "spatie/laravel-translatable": "^4.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.16", "orchestra/testbench": "^6.0", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { diff --git a/config/tags.php b/config/tags.php index 4bcdf32..0b96549 100644 --- a/config/tags.php +++ b/config/tags.php @@ -4,7 +4,7 @@ /* * The given function generates a URL friendly "slug" from the tag name property before saving it. - * Defaults to Str::slug (https://laravel.com/docs/5.8/helpers#method-str-slug) + * Defaults to Str::slug (https://laravel.com/docs/master/helpers#method-str-slug) */ 'slugger' => null, diff --git a/database/migrations/create_tag_tables.php.stub b/database/migrations/create_tag_tables.php.stub index 9a86a3e..b96036b 100644 --- a/database/migrations/create_tag_tables.php.stub +++ b/database/migrations/create_tag_tables.php.stub @@ -10,24 +10,21 @@ class CreateTagTables extends Migration { Schema::create('tags', function (Blueprint $table) { $table->id(); + $table->json('name'); $table->json('slug'); $table->string('type')->nullable(); $table->integer('order_column')->nullable(); + $table->timestamps(); }); Schema::create('taggables', function (Blueprint $table) { $table->foreignId('tag_id')->constrained()->cascadeOnDelete(); + $table->morphs('taggable'); $table->unique(['tag_id', 'taggable_id', 'taggable_type']); }); } - - public function down() - { - Schema::drop('taggables'); - Schema::drop('tags'); - } } diff --git a/docs/_index.md b/docs/_index.md index 08717ff..da660db 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -1,5 +1,5 @@ --- -title: v3 +title: v4 slogan: A powerful tagging package. Batteries included. githubUrl: https://github.com/spatie/laravel-tags branch: master diff --git a/docs/advanced-usage/adding-translations.md b/docs/advanced-usage/adding-translations.md index 8e8f63c..05d8515 100644 --- a/docs/advanced-usage/adding-translations.md +++ b/docs/advanced-usage/adding-translations.md @@ -23,7 +23,7 @@ $tag->name // returns the name of the tag in current locale of your app. The translations of the tags are stored in the `name` column of the `tags` table. It's a `json` column. To find a tag with a specific translation you can just use Laravel's query builder which has support for `json` columns. ```php - \Spatie\Tags\Tag + \Spatie\Tags\Tag::query() ->where('name->fr', 'mon tag') ->first(); ``` diff --git a/docs/advanced-usage/using-types.md b/docs/advanced-usage/using-types.md index e5883c1..e9b43ce 100644 --- a/docs/advanced-usage/using-types.md +++ b/docs/advanced-usage/using-types.md @@ -17,7 +17,7 @@ In addition to strings, all methods mentioned in the basic usage section can tak ```php $newsItem->attachTag($tagWithType); $newsItem->detachTag($tagWithType); -... +// ... ``` In addition to `syncTags`, an additional method called `syncTagsWithType` is available for syncing tags on a per-type basis: diff --git a/docs/advanced-usage/using-your-own-tag-model.md b/docs/advanced-usage/using-your-own-tag-model.md index bbbe79f..e566bdd 100644 --- a/docs/advanced-usage/using-your-own-tag-model.md +++ b/docs/advanced-usage/using-your-own-tag-model.md @@ -7,10 +7,11 @@ You might want to override some functionality of the `Spatie\Tags\Tag` or add so ```php use Illuminate\Database\Eloquent\Model; +use Spatie\Tags\HasTags; class YourModel extends Model { - use \Spatie\Tags\HasTags; + use HasTags; public static function getTagClassName(): string { @@ -21,7 +22,7 @@ class YourModel extends Model Then you need to override the `tags()` method from the same trait to tell Laravel that it still needs to look for `tags_id` column for tags relation instead of `your_tag_model_id`: -``` +```php use Illuminate\Database\Eloquent\Relations\MorphToMany; public function tags(): MorphToMany diff --git a/docs/basic-usage/using-tags.md b/docs/basic-usage/using-tags.md index 201e67a..051f30c 100644 --- a/docs/basic-usage/using-tags.md +++ b/docs/basic-usage/using-tags.md @@ -6,9 +6,12 @@ weight: 1 To make an Eloquent model taggable just add the `\Spatie\Tags\HasTags` trait to it: ```php -class YourModel extends \Illuminate\Database\Eloquent\Model +use Illuminate\Database\Eloquent\Model; +use Spatie\Tags\HasTags; + +class YourModel extends Model { - use \Spatie\Tags\HasTags; + use HasTags; ... } @@ -95,4 +98,4 @@ You can fetch a collection of all registered tag types by using the static metho ```php Tag::getTypes(); -``` \ No newline at end of file +``` diff --git a/docs/installation-and-setup.md b/docs/installation-and-setup.md index 5877bd0..8c5258a 100644 --- a/docs/installation-and-setup.md +++ b/docs/installation-and-setup.md @@ -9,8 +9,6 @@ You can install the package via composer: composer require spatie/laravel-tags ``` -The service provider will automatically be registered. - You can publish the migration with: ```bash php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="migrations" @@ -30,7 +28,6 @@ php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="c This is the contents of the published config file: ```php - Latest Version on Packagist Software License - Build Status - Quality Score Total Downloads diff --git a/docs/postcardware.md b/docs/postcardware.md index 348a79f..617f560 100644 --- a/docs/postcardware.md +++ b/docs/postcardware.md @@ -5,6 +5,6 @@ weight: 2 You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. -Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium. +Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium. -The best postcards will get published on the [open source section](https://spatie.be/en/opensource/postcards) on our website. +All postcards will get published on the [open source section](https://spatie.be/open-source/postcards) on our website. diff --git a/docs/requirements.md b/docs/requirements.md index bbe0f39..bbe1f88 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -3,4 +3,4 @@ title: Requirements weight: 3 --- -This package requires Laravel 8 or higher, PHP 7.4 or higher and a database that supports `json` fields such as MySQL 5.7.8 or higher. +This package requires Laravel 8 or higher, PHP 8 or higher and a database that supports `json` fields such as MySQL 5.7.8 or higher. diff --git a/src/HasSlug.php b/src/HasSlug.php index 8299b4c..d09db81 100644 --- a/src/HasSlug.php +++ b/src/HasSlug.php @@ -10,7 +10,11 @@ public static function bootHasSlug() { static::saving(function (Model $model) { collect($model->getTranslatedLocales('name')) - ->each(fn (string $locale) => $model->setTranslation('slug', $locale, $model->generateSlug($locale))); + ->each(fn (string $locale) => $model->setTranslation( + 'slug', + $locale, + $model->generateSlug($locale) + )); }); } @@ -18,7 +22,7 @@ protected function generateSlug(string $locale): string { $slugger = config('tags.slugger'); - $slugger = $slugger ?: '\Illuminate\Support\Str::slug'; + $slugger ??= '\Illuminate\Support\Str::slug'; return call_user_func($slugger, $this->getTranslation('name', $locale)); } diff --git a/src/HasTags.php b/src/HasTags.php index 594c080..651ffb2 100644 --- a/src/HasTags.php +++ b/src/HasTags.php @@ -2,6 +2,7 @@ namespace Spatie\Tags; +use ArrayAccess; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; @@ -20,11 +21,13 @@ public static function getTagClassName(): string public static function bootHasTags() { static::created(function (Model $taggableModel) { - if (count($taggableModel->queuedTags) > 0) { - $taggableModel->attachTags($taggableModel->queuedTags); - - $taggableModel->queuedTags = []; + if (count($taggableModel->queuedTags) === 0) { + return; } + + $taggableModel->attachTags($taggableModel->queuedTags); + + $taggableModel->queuedTags = []; }); static::deleted(function (Model $deletedModel) { @@ -41,10 +44,7 @@ public function tags(): MorphToMany ->ordered(); } - /** - * @param string $locale - */ - public function tagsTranslated($locale = null): MorphToMany + public function tagsTranslated(string | null $locale = null): MorphToMany { $locale = ! is_null($locale) ? $locale : app()->getLocale(); @@ -56,10 +56,7 @@ public function tagsTranslated($locale = null): MorphToMany ->ordered(); } - /** - * @param string|array|\ArrayAccess|\Spatie\Tags\Tag $tags - */ - public function setTagsAttribute($tags) + public function setTagsAttribute(string | array | ArrayAccess | Tag $tags) { if (! $this->exists) { $this->queuedTags = $tags; @@ -70,51 +67,48 @@ public function setTagsAttribute($tags) $this->syncTags($tags); } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param array|\ArrayAccess|\Spatie\Tags\Tag $tags - * - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeWithAllTags(Builder $query, $tags, string $type = null): Builder - { + public function scopeWithAllTags( + Builder $query, + array | ArrayAccess | Tag $tags, + string $type = null, + ): Builder { $tags = static::convertToTags($tags, $type); collect($tags)->each(function ($tag) use ($query) { $query->whereHas('tags', function (Builder $query) use ($tag) { - $query->where('tags.id', $tag ? $tag->id : 0); + $query->where('tags.id', $tag->id ?? 0); }); }); return $query; } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param array|\ArrayAccess|\Spatie\Tags\Tag $tags - * - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeWithAnyTags(Builder $query, $tags, string $type = null): Builder - { + public function scopeWithAnyTags( + Builder $query, + array | ArrayAccess | Tag $tags, + string $type = null, + ): Builder { $tags = static::convertToTags($tags, $type); - return $query->whereHas('tags', function (Builder $query) use ($tags) { - $tagIds = collect($tags)->pluck('id'); + return $query + ->whereHas('tags', function (Builder $query) use ($tags) { + $tagIds = collect($tags)->pluck('id'); - $query->whereIn('tags.id', $tagIds); - }); + $query->whereIn('tags.id', $tagIds); + }); } public function scopeWithAllTagsOfAnyType(Builder $query, $tags): Builder { $tags = static::convertToTagsOfAnyType($tags); - collect($tags)->each(function ($tag) use ($query) { - $query->whereHas('tags', function (Builder $query) use ($tag) { - $query->where('tags.id', $tag ? $tag->id : 0); + collect($tags) + ->each(function ($tag) use ($query) { + $query->whereHas( + 'tags', + fn (Builder $query) => $query->where('tags.id', $tag ? $tag->id : 0) + ); }); - }); return $query; } @@ -123,26 +117,21 @@ public function scopeWithAnyTagsOfAnyType(Builder $query, $tags): Builder { $tags = static::convertToTagsOfAnyType($tags); - return $query->whereHas('tags', function (Builder $query) use ($tags) { - $tagIds = collect($tags)->pluck('id'); + $tagIds = collect($tags)->pluck('id'); - $query->whereIn('tags.id', $tagIds); - }); + + return $query->whereHas( + 'tags', + fn (Builder $query) => $query->whereIn('tags.id', $tagIds) + ); } public function tagsWithType(string $type = null): Collection { - return $this->tags->filter(function (Tag $tag) use ($type) { - return $tag->type === $type; - }); + return $this->tags->filter(fn (Tag $tag) => $tag->type === $type); } - /** - * @param array|\ArrayAccess|\Spatie\Tags\Tag $tags - * @param string|null $type - * @return $this - */ - public function attachTags($tags, string $type = null) + public function attachTags(array | ArrayAccess | Tag $tags, string $type = null): static { $className = static::getTagClassName(); @@ -153,53 +142,28 @@ public function attachTags($tags, string $type = null) return $this; } - /** - * @param string|\Spatie\Tags\Tag $tag - * - * @param string|null $type - * @return $this - */ - public function attachTag($tag, string $type = null) + public function attachTag(string | Tag $tag, string | null $type = null) { return $this->attachTags([$tag], $type); } - /** - * @param array|\ArrayAccess $tags - * - * @param string|null $type - * @return $this - */ - public function detachTags($tags, string $type = null) + public function detachTags(array | ArrayAccess $tags, string | null $type = null): static { $tags = static::convertToTags($tags, $type); collect($tags) ->filter() - ->each(function (Tag $tag) { - $this->tags()->detach($tag); - }); + ->each(fn (Tag $tag) => $this->tags()->detach($tag)); return $this; } - /** - * @param string|\Spatie\Tags\Tag $tag - * - * @param string|null $type - * @return $this - */ - public function detachTag($tag, string $type = null) + public function detachTag(string | Tag $tag, string | null $type = null): static { return $this->detachTags([$tag], $type); } - /** - * @param array|\ArrayAccess $tags - * - * @return $this - */ - public function syncTags($tags) + public function syncTags(array | ArrayAccess $tags): static { $className = static::getTagClassName(); @@ -210,13 +174,7 @@ public function syncTags($tags) return $this; } - /** - * @param array|\ArrayAccess $tags - * @param string|null $type - * - * @return $this - */ - public function syncTagsWithType($tags, string $type = null) + public function syncTagsWithType(array | ArrayAccess $tags, string | null $type = null): static { $className = static::getTagClassName(); @@ -257,14 +215,7 @@ protected static function convertToTagsOfAnyType($values, $locale = null) }); } - /** - * Use in place of eloquent's sync() method so that the tag type may be optionally specified. - * - * @param $ids - * @param string|null $type - * @param bool $detaching - */ - protected function syncTagIds($ids, string $type = null, $detaching = true) + protected function syncTagIds($ids, string | null $type = null, $detaching = true): void { $isUpdated = false; @@ -280,7 +231,7 @@ protected function syncTagIds($ids, string $type = null, $detaching = true) $tagModel->getTable(), 'taggables.tag_id', '=', - $tagModel->getTable().'.'.$tagModel->getKeyName() + $tagModel->getTable() . '.' . $tagModel->getKeyName() ) ->where('tags.type', $type); }) diff --git a/src/Tag.php b/src/Tag.php index c561b25..7e2fcf9 100644 --- a/src/Tag.php +++ b/src/Tag.php @@ -2,6 +2,7 @@ namespace Spatie\Tags; +use ArrayAccess; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection as DbCollection; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -13,9 +14,12 @@ class Tag extends Model implements Sortable { - use SortableTrait, HasTranslations, HasSlug, HasFactory; + use SortableTrait; + use HasTranslations; + use HasSlug; + use HasFactory; - public $translatable = ['name', 'slug']; + public array $translatable = ['name', 'slug']; public $guarded = []; @@ -32,18 +36,14 @@ public function scopeContaining(Builder $query, string $name, $locale = null): B { $locale = $locale ?? app()->getLocale(); - return $query->whereRaw('lower('.$this->getQuery()->getGrammar()->wrap('name->'.$locale).') like ?', ['%'.mb_strtolower($name).'%']); + return $query->whereRaw('lower(' . $this->getQuery()->getGrammar()->wrap('name->' . $locale) . ') like ?', ['%' . mb_strtolower($name) . '%']); } - /** - * @param string|array|\ArrayAccess $values - * @param string|null $type - * @param string|null $locale - * - * @return \Spatie\Tags\Tag|static - */ - public static function findOrCreate($values, string $type = null, string $locale = null) - { + public static function findOrCreate( + string | array | ArrayAccess $values, + string | null $type = null, + string | null $locale = null, + ): Collection | Tag | static { $tags = collect($values)->map(function ($value) use ($type, $locale) { if ($value instanceof self) { return $value; diff --git a/src/TagsServiceProvider.php b/src/TagsServiceProvider.php index 617a2be..ef54d3d 100644 --- a/src/TagsServiceProvider.php +++ b/src/TagsServiceProvider.php @@ -2,23 +2,16 @@ namespace Spatie\Tags; -use Illuminate\Support\ServiceProvider; +use Spatie\LaravelPackageTools\Package; +use Spatie\LaravelPackageTools\PackageServiceProvider; -class TagsServiceProvider extends ServiceProvider +class TagsServiceProvider extends PackageServiceProvider { - public function boot() + public function configurePackage(Package $package): void { - if ($this->app->runningInConsole()) { - if (! class_exists('CreateTagTables')) { - $timestamp = date('Y_m_d_His', time()); - $this->publishes([ - __DIR__.'/../database/migrations/create_tag_tables.php.stub' => database_path('migrations/'.$timestamp.'_create_tag_tables.php'), - ], 'migrations'); - } - - $this->publishes([ - __DIR__.'/../config/tags.php' => config_path('tags.php'), - ], 'config'); - } + $package + ->name('laravel-tags') + ->hasConfigFile() + ->hasMigration('create_tag_tables'); } } diff --git a/tests/HasTagsScopesTest.php b/tests/HasTagsScopesTest.php index 5c0c009..0a7e23f 100644 --- a/tests/HasTagsScopesTest.php +++ b/tests/HasTagsScopesTest.php @@ -4,7 +4,7 @@ use Spatie\Tags\Tag; use Spatie\Tags\Test\TestCase; -use Spatie\Tags\Test\TestModel; +use Spatie\Tags\Test\TestClasses\TestModel; class HasTagsScopesTest extends TestCase { diff --git a/tests/HasTagsTest.php b/tests/HasTagsTest.php index fff6328..b13eca5 100644 --- a/tests/HasTagsTest.php +++ b/tests/HasTagsTest.php @@ -4,14 +4,13 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany; use Spatie\Tags\Tag; -use Spatie\Tags\Test\TestAnotherModel; use Spatie\Tags\Test\TestCase; -use Spatie\Tags\Test\TestModel; +use Spatie\Tags\Test\TestClasses\TestAnotherModel; +use Spatie\Tags\Test\TestClasses\TestModel; class HasTagsTest extends TestCase { - /** @var \Spatie\Tags\Test\TestModel */ - protected $testModel; + protected TestModel $testModel; public function setUp(): void { diff --git a/tests/HasTagsTranslatedTest.php b/tests/HasTagsTranslatedTest.php index 6e4e59a..d7f1afd 100644 --- a/tests/HasTagsTranslatedTest.php +++ b/tests/HasTagsTranslatedTest.php @@ -3,7 +3,7 @@ namespace Spatie\Translatable\Test; use Spatie\Tags\Test\TestCase; -use Spatie\Tags\Test\TestModel; +use Spatie\Tags\Test\TestClasses\TestModel; class HasTagsTranslatedTest extends TestCase { diff --git a/tests/TagTest.php b/tests/TagTest.php index eb02553..7e8d905 100644 --- a/tests/TagTest.php +++ b/tests/TagTest.php @@ -45,7 +45,7 @@ public function it_automatically_generates_a_slug() /** @test */ public function it_uses_str_slug_if_config_slugger_value_is_empty() { - app('config')->set('tags.slugger', null); + config()->set('tags.slugger', null); $tag = Tag::findOrCreateFromString('this is a tag'); @@ -55,7 +55,7 @@ public function it_uses_str_slug_if_config_slugger_value_is_empty() /** @test */ public function it_can_use_a_custom_slugger() { - app('config')->set('tags.slugger', 'strtoupper'); + config()->set('tags.slugger', 'strtoupper'); $tag = Tag::findOrCreateFromString('this is a tag'); diff --git a/tests/TestAnotherModel.php b/tests/TestClasses/TestAnotherModel.php similarity index 85% rename from tests/TestAnotherModel.php rename to tests/TestClasses/TestAnotherModel.php index 6256bb1..694522b 100644 --- a/tests/TestAnotherModel.php +++ b/tests/TestClasses/TestAnotherModel.php @@ -1,6 +1,6 @@