Skip to content

Commit db00673

Browse files
scott graysonscott grayson
authored andcommitted
Merge remote changes and add Filament resource
2 parents ab1584b + 4284998 commit db00673

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

database/seeders/LibrarySeeder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ public function run(): void
1616
// Get the first user as the creator
1717
$user = \App\Models\User::first();
1818

19+
<<<<<<< HEAD
1920
if (!$user) {
21+
=======
22+
if (! $user) {
23+
>>>>>>> 428499810cee073c27187b76f36c914dcdf38c37
2024
$this->command->warn('No users found. Please create a user first.');
25+
2126
return;
2227
}
2328

src/FilamentLibraryServiceProvider.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tapp\FilamentLibrary;
44

5-
use Filament\Support\Assets\AlpineComponent;
65
use Filament\Support\Assets\Asset;
76
use Filament\Support\Assets\Css;
87
use Filament\Support\Assets\Js;
@@ -49,7 +48,6 @@ public function configurePackage(Package $package): void
4948
$package->hasMigrations($this->getMigrations());
5049
}
5150

52-
5351
if (file_exists($package->basePath('/../resources/lang'))) {
5452
$package->hasTranslations();
5553
}
@@ -158,5 +156,4 @@ protected function getMigrations(): array
158156
'2024_01_01_000001_create_library_item_permissions_table',
159157
];
160158
}
161-
162159
}

src/Models/LibraryItem.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
class LibraryItem extends Model implements HasMedia
1616
{
17-
use HasFactory, SoftDeletes, InteractsWithMedia;
17+
use HasFactory;
18+
use InteractsWithMedia;
19+
use SoftDeletes;
1820

1921
protected $fillable = [
2022
'name',
@@ -44,7 +46,7 @@ protected static function boot(): void
4446
});
4547

4648
static::updating(function (self $item) {
47-
if ($item->isDirty('name') && !$item->isDirty('slug')) {
49+
if ($item->isDirty('name') && ! $item->isDirty('slug')) {
4850
$item->slug = static::generateUniqueSlug($item->name, $item->parent_id, $item->id);
4951
}
5052
});
@@ -105,9 +107,9 @@ public function scopeForUser($query, $user)
105107
{
106108
return $query->where(function ($q) use ($user) {
107109
$q->where('created_by', $user->id)
108-
->orWhereHas('permissions', function ($permissionQuery) use ($user) {
109-
$permissionQuery->where('user_id', $user->id);
110-
});
110+
->orWhereHas('permissions', function ($permissionQuery) use ($user) {
111+
$permissionQuery->where('user_id', $user->id);
112+
});
111113
});
112114
}
113115

@@ -160,6 +162,7 @@ public function getSizeAttribute(): ?int
160162
}
161163

162164
$media = $this->getFirstMedia('files');
165+
163166
return $media ? $media->size : null;
164167
}
165168

@@ -190,7 +193,7 @@ public function registerMediaCollections(): void
190193
/**
191194
* Register media conversions.
192195
*/
193-
public function registerMediaConversions(Media $media = null): void
196+
public function registerMediaConversions(?Media $media = null): void
194197
{
195198
$this->addMediaConversion('thumb')
196199
->width(300)
@@ -210,7 +213,7 @@ protected static function generateUniqueSlug(string $name, ?int $parentId = null
210213

211214
while (static::where('slug', $slug)
212215
->where('parent_id', $parentId)
213-
->when($excludeId, fn($q) => $q->where('id', '!=', $excludeId))
216+
->when($excludeId, fn ($q) => $q->where('id', '!=', $excludeId))
214217
->exists()) {
215218
$slug = $baseSlug . '-' . $counter;
216219
$counter++;

src/Traits/HasLibraryAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getAccessibleLibraryItems()
6666
*/
6767
public function getAccessibleRootLibraryItems()
6868
{
69-
if (!$this->canViewRootLibraryItems()) {
69+
if (! $this->canViewRootLibraryItems()) {
7070
return collect();
7171
}
7272

0 commit comments

Comments
 (0)