From f79fbfb7e532d81725de48ee4ac284423f91d9d0 Mon Sep 17 00:00:00 2001 From: cbl Date: Mon, 3 May 2021 00:22:33 +0200 Subject: [PATCH] renamed Filable trait to HasFiles --- src/Concerns/{Fileable.php => HasFiles.php} | 4 ++-- src/Models/File.php | 9 ++++----- tests/Models/Post.php | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) rename src/Concerns/{Fileable.php => HasFiles.php} (97%) diff --git a/src/Concerns/Fileable.php b/src/Concerns/HasFiles.php similarity index 97% rename from src/Concerns/Fileable.php rename to src/Concerns/HasFiles.php index 8c2eb50..0684f94 100644 --- a/src/Concerns/Fileable.php +++ b/src/Concerns/HasFiles.php @@ -19,9 +19,9 @@ * * @mixin Model */ -trait Fileable +trait HasFiles { - public static function bootFileable(): void + public static function bootHasFiles(): void { static::deleting(static function (self $model): ?bool { if (array_key_exists(SoftDeletes::class, class_uses_recursive($model))) { diff --git a/src/Models/File.php b/src/Models/File.php index dc51085..31b23fe 100644 --- a/src/Models/File.php +++ b/src/Models/File.php @@ -2,9 +2,8 @@ namespace Astrotomic\Fileable\Models; -use Astrotomic\Fileable\Concerns\Fileable; use Astrotomic\Fileable\Contracts\File as FileContract; -use Astrotomic\Fileable\Contracts\Fileable as FileableContract; +use Astrotomic\Fileable\Contracts\Fileable; use Astrotomic\LaravelEloquentUuid\Eloquent\Concerns\UsesUUID; use Closure; use Illuminate\Contracts\Filesystem\Filesystem; @@ -44,7 +43,7 @@ * @method static Builder|File query() * @method static Builder|MorphMany|File whereCreatedAt($value) * @method static Builder|MorphMany|File whereDisk($value) - * @method static Builder|MorphMany|File whereFileable(FileableContract $fileable) + * @method static Builder|MorphMany|File whereFileable(Fileable $fileable) * @method static Builder|MorphMany|File whereFileableId($value) * @method static Builder|MorphMany|File whereFileableType($value) * @method static Builder|MorphMany|File whereFilename($value) @@ -106,11 +105,11 @@ public function fileable(): MorphTo /** * @param Builder $query - * @param FileableContract|Model $fileable + * @param Fileable|Model $fileable * * @return Builder */ - public function scopeWhereFileable(Builder $query, FileableContract $fileable): Builder + public function scopeWhereFileable(Builder $query, Fileable $fileable): Builder { return $query->where( fn (Builder $q) => $q diff --git a/tests/Models/Post.php b/tests/Models/Post.php index 08af6cb..93f974c 100644 --- a/tests/Models/Post.php +++ b/tests/Models/Post.php @@ -2,11 +2,11 @@ namespace Astrotomic\Fileable\Tests\Models; -use Astrotomic\Fileable\Concerns\Fileable; -use Astrotomic\Fileable\Contracts\Fileable as FileableContract; +use Astrotomic\Fileable\Concerns\HasFiles; +use Astrotomic\Fileable\Contracts\Fileable; use Illuminate\Database\Eloquent\Model; -class Post extends Model implements FileableContract +class Post extends Model implements Fileable { - use Fileable; + use HasFiles; }