Skip to content

Instantly share code, notes, and snippets.

View erdum's full-sized avatar

Erdum erdum

View GitHub Profile
@erdum
erdum / toast.html
Created October 7, 2024 07:42
Simple Toast
<div id="toast" class="hidden">
<span id="toast-message">Success message</span>
</div>
<script>
function showToast(message, type = 'success') {
const toast = document.getElementById('toast');
const toastMessage = document.getElementById('toast-message');
toastMessage.textContent = message;
@erdum
erdum / image-loader.html
Created September 1, 2024 06:54
Large image loader
<script>
const largeImageUrl = '/path/to/large-image.jpg';
const bodyElement = document.querySelector('body');
const largeImage = new Image();
largeImage.src = largeImageUrl;
largeImage.onload = () => {
bodyElement.style.backgroundImage = `url(${largeImageUrl})`;
};
</script>
@erdum
erdum / AssignRequestId.php
Last active July 23, 2024 07:16
Assign Requests ID Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class AssignRequestId
{
@erdum
erdum / RequestLogger.php
Last active May 13, 2024 07:45
Larvel Http Request logger Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Log;
class RequestLogger
{
/**
@erdum
erdum / StoreImages.php
Created May 7, 2024 13:14
Convert And Store Images In WebP formate Queue Job
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\UploadedFile;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
@erdum
erdum / CheckUserPermissions.php
Created March 19, 2024 04:47
Restrict users from accessing routes based on their permissions (Middleware)
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
class CheckUserPermissions
@erdum
erdum / FirestoreNotificationService.php
Created March 18, 2024 04:45
Realtime Notification Mechanism Using Firestore
<?php
namespace App\Services;
use Kreait\Firebase\Factory;
use Google\Cloud\Firestore\FieldValue;
use Throwable;
class FirestoreNotificationService
{
@erdum
erdum / StripeService.php
Last active May 15, 2024 18:50
Stripe API Service
<?php
namespace App\Services;
use Throwable;
use App\Models\User;
use App\Models\UserCard;
use App\Exceptions\StripeApiException;
use Stripe\StripeClient;
@erdum
erdum / FirebaseAuthService.php
Created March 12, 2024 04:45
Authentication Service Class for Laravel REST API
<?php
namespace App\Services;
use Kreait\Firebase\Factory;
use App\Jobs\ProcessEmail;
use App\Exceptions\InvalidIdTokenException;
use App\Exceptions\UserAlreadyRegisteredException;
use App\Exceptions\UserBlockedException;
use App\Exceptions\AccessForbiddenException;
@erdum
erdum / stripe_add_card.html
Created March 8, 2024 07:30
Stripe Add Card Form (for testing)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Payment Form</title>
<!-- Include Stripe.js -->
<script src="https://js.stripe.com/v3/"></script>
</head>