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 / VerifyProjectIsBillable.php
Created December 16, 2023 14:02
Extending the Filament Middleware to verify if a tenant is billable. Read more and learn an even better way: https://silvanhagen.com/free-users-filament-laravel-spark/
<?php
namespace App\Http\Middleware;
use Filament\Billing\Providers\Http\Middleware\VerifySparkBillableIsSubscribed;
use Filament\Facades\Filament;
class VerifyProjectIsBillable extends VerifySparkBillableIsSubscribed
{
public function handle($request, $next, $subscription = 'default', $plan = null)
@neverything
neverything / FeedbackResource.php
Created December 16, 2023 13:51
⚠️ Don't do it this way. Read about it on my blog https://silvanhagen.com/free-users-filament-laravel-spark/
<?php
namespace App\Filament\Resources;
// use ...
class FeedbackResource extends Resource
{
// ... rest of the class
<?php
// Custom HasPagination interface
namespace App\Http\Integrations\GithubApi\Contracts;
use Saloon\Http\Request;
use Saloon\PaginationPlugin\Paginator;
interface HasPagination
<head>
<meta property="og:image" content="https://wireinthewild.com/storage/share/mailcoach.png">
<meta name="twitter:image" content="https://wireinthewild.com/storage/share/mailcoach.png">
</head>
<?php
namespace App\Listeners;
use App\Events\ProjectPublishedEvent;
use App\Models\Project;
use Illuminate\Support\Facades\Artisan;
class RunGenerateShareImageCommand
{
<?php
namespace App\Console\Commands;
use App\Models\Project;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use Spatie\Browsershot\Browsershot;
class GenerateOpenGraphImage extends Command
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="scroll-smooth">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<title>{{ $project->name }} | Share Image</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
@neverything
neverything / functions.php
Last active October 27, 2023 13:53
WordPress: Strip image metadata on upload to the media library using Imagick. Learn more https://silvanhagen.com/strip-image-meta-data-wordpress/
<?php
add_filter( 'wp_handle_upload', 'yourprefix_strip_metadata_from_images_on_upload' );
function yourprefix_strip_metadata_from_images_on_upload( array $upload ): array {
if ( ! in_array( $upload['type'], array( 'image/jpeg', 'image/png', 'image/gif' ), true ) ) {
return $upload;
}
try {
yourprefix_strip_metadata_from_image( $upload['file'] );
<?php
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Rule;
<?php
// On top of the User model add:
use App\Notifications\MagicLoginLink;
use Grosv\LaravelPasswordlessLogin\PasswordlessLogin;
// In the model class, add the following methods:
public function sendMagicLoginLinkNotification(): void
{
$this->notify(new MagicLoginLink($this->getMagicLoginLink()));