mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-07-02 09:00:23 +00:00
✨ Refactor components and models:
- 🔥 Removed deprecated `placeholder-pattern` component. - 🧹 Simplified and cleaned up Blade views by removing unused comments and sections. - 🗂️ Extracted `SetsCreatedBy` concern for DRY and reused it across models. - 🔧 Consolidated configuration for Horizon `authorized_nostr_keys`. - 🧪 Migrated media conversion to use new Spatie enums for clarity. - ♻️ Replaced repetitive link rendering with dynamic rendering in meetups and services views.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\SetsCreatedBy;
|
||||
use App\Support\CustomFeedItem;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -11,7 +12,7 @@ use Illuminate\Support\Facades\Cookie;
|
||||
use Spatie\EloquentSortable\Sortable;
|
||||
use Spatie\EloquentSortable\SortableTrait;
|
||||
use Spatie\Feed\Feedable;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\Image\Enums\Fit;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
@@ -27,6 +28,7 @@ class LibraryItem extends Model implements Feedable, HasMedia, Sortable
|
||||
use HasStatuses;
|
||||
use HasTags;
|
||||
use InteractsWithMedia;
|
||||
use SetsCreatedBy;
|
||||
use SortableTrait;
|
||||
|
||||
/**
|
||||
@@ -60,15 +62,6 @@ class LibraryItem extends Model implements Feedable, HasMedia, Sortable
|
||||
->get();
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
if (! $model->created_by) {
|
||||
$model->created_by = auth()->id();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
@@ -81,13 +74,13 @@ class LibraryItem extends Model implements Feedable, HasMedia, Sortable
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
->fit(Manipulations::FIT_CROP, 300, 300)
|
||||
->fit(Fit::Crop, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('seo')
|
||||
->fit(Manipulations::FIT_CROP, 1200, 630)
|
||||
->fit(Fit::Crop, 1200, 630)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
->fit(Manipulations::FIT_CROP, 130, 130)
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
}
|
||||
@@ -149,17 +142,4 @@ class LibraryItem extends Model implements Feedable, HasMedia, Sortable
|
||||
->link(url()->route('article.view', ['libraryItem' => $this]))
|
||||
->authorName($this->lecturer->name);
|
||||
}
|
||||
|
||||
public static function searchLibraryItems($type, $value = null)
|
||||
{
|
||||
$query = self::query()
|
||||
->where('type', $type)
|
||||
->latest('id');
|
||||
|
||||
if ($value) {
|
||||
$query->whereLike('name', "%{$value}%");
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user