1414
1515class 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 ++;
0 commit comments