Skip to content

Instantly share code, notes, and snippets.

View neverything's full-sized avatar
🍀
Good vibes for you

Silvan Hagen neverything

🍀
Good vibes for you
View GitHub Profile
@neverything
neverything / UpdateMediaInfoCommand.php
Created October 18, 2024 09:02
Set Image and Video dimension for the Spatie Laravel Media Library as custom properties: https://silvanhagen.com/writing/image-and-video-dimensions-laravel-media-library
<?php
namespace App\Console\Commands;
use App\Actions\Media\UpdateMediaInfoAction;
use Illuminate\Console\Command;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class UpdateMediaInfoCommand extends Command
{
@neverything
neverything / UpdateMediaInfoJob.php
Created October 18, 2024 08:17
Set Image and Video dimension for the Spatie Laravel Media Library as custom properties: https://silvanhagen.com/writing/image-and-video-dimensions-laravel-media-library
<?php
namespace App\Jobs;
use App\Actions\Media\UpdateMediaInfoAction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Attributes\DeleteWhenMissingModels;
use Illuminate\Queue\InteractsWithQueue;
@neverything
neverything / UpdateMediaInfoAction.php
Last active October 18, 2024 08:04
Set Image and Video dimension for the Spatie Laravel Media Library as custom properties: https://silvanhagen.com/writing/image-and-video-dimensions-laravel-media-library
<?php
namespace App\Actions\Media;
use Exception;
use FFMpeg\FFProbe;
use Illuminate\Support\Facades\Log;
use Spatie\Image\Image;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
@neverything
neverything / MediaObserver.php
Last active October 18, 2024 06:22
Set Image and Video dimension for the Spatie Laravel Media Library as custom properties: https://silvanhagen.com/writing/image-and-video-dimensions-laravel-media-library
<?php
namespace App\Observers;
use App\Actions\Media\UpdateMediaInfoAction;
use App\Jobs\UpdateMediaInfoJob;
use Illuminate\Support\Facades\Log;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class MediaObserver
@neverything
neverything / LinkResource.php
Created August 27, 2024 07:50
Background File Uploads using Filament Forms, FilePond, Livewire and Alpine.js: https://silvanhagen.com/writing/background-file-upload-in-filament-forms
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\LinkResource\Pages;
use App\Models\Link;
use AshAllenDesign\FaviconFetcher\Facades\Favicon;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Set;
@neverything
neverything / functions.php
Last active August 13, 2024 14:14
Conditionally Redirect in WordPress with full knowledge of the queried content: https://silvanhagen.com/writing/conditionally-redirect-in-wordpress/
<?php
/**
* Redirect job ads to their parent page if they are not published.
*
* @link https://developer.wordpress.org/reference/hooks/template_redirect/
* @link https://developer.wordpress.org/reference/functions/is_404/
* @link https://developer.wordpress.org/reference/functions/get_queried_object_id/
* @link https://developer.wordpress.org/reference/functions/get_post_meta/
* @link https://developer.wordpress.org/reference/functions/get_post_status/
* @link https://developer.wordpress.org/reference/functions/wp_get_post_parent_id/
@neverything
neverything / AdminPanelProvider.php
Created August 7, 2024 13:58
Filament Onboarding Manager Pro: Add Tenant Switcher to Onboarding Wizard
class AdminPanelProvider extends PanelProvider
{
public function boot(): void
{
FilamentView::registerRenderHook(
PanelsRenderHook::BODY_START,
fn (): string => Blade::render('<x-tenant-menu />'),
scopes: [Onboard::class]
);
}
@neverything
neverything / functions.php
Created July 15, 2024 09:24
GenerateBlocks Accordion Block as Mega Menu in WordPress: https://silvanhagen.com/writing/wordpress-mega-menu-blocks
<?php
namespace TTF_WP_Mega_Menu;
function setup(): void {
// Stylesheet in the editor.
add_editor_style( 'style.css' );
}
add_action( 'after_setup_theme', __NAMESPACE__ . '\setup' );
@neverything
neverything / style.css
Created July 15, 2024 09:21
GenerateBlocks Accordion Block as Mega Menu in WordPress: https://silvanhagen.com/writing/wordpress-mega-menu-blocks
.navigation-overlay {
position: fixed;
top: 150px;
left: 0;
right: 0;
bottom: 0;
height: calc(100dvh - 150px);
max-width: 100% !important;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
@neverything
neverything / functions.js
Created July 15, 2024 09:18
GenerateBlocks Accordion Block as Mega Menu in WordPress: https://silvanhagen.com/writing/wordpress-mega-menu-blocks
document.addEventListener('DOMContentLoaded', function () {
// Get all accordion items
const allItems = document.querySelectorAll('header .gb-accordion__item');
// Function to close all other accordion items
function closeOtherAccordionItems() {
allItems.forEach(item => {
item.classList.remove('gb-accordion__item-open');
let toggle = item.querySelector('.gb-accordion__toggle');
toggle.setAttribute('aria-expanded', 'false');