Skip to content

Instantly share code, notes, and snippets.

View atomjoy's full-sized avatar

Atomjoy atomjoy

View GitHub Profile
@atomjoy
atomjoy / ExpiredToken.php
Last active August 8, 2025 15:10
Laravel Sanctum Expired Token Middleware
<?php
namespace App\Http\Middleware\Api;
use Closure;
use Illuminate\Http\Request;
use Laravel\Sanctum\PersonalAccessToken;
/**
* Sanctum expired token middleware.
@atomjoy
atomjoy / Sanctum-Spatie-Permissions-Laravel.md
Last active September 3, 2025 12:04
Jak dodać role i uprawnienia do zalogowanego użytkownika z Sanctum w Laravel.

Laravel Sanctum Spatie Permissions

Jak dodać role i uprawnienia do zalogowanego użytkownika z Sanctum w Laravel.

Zalogowany user

W sanctum ładujesz relacje za pomocą ->fresh(['roles','permissions']) dla zalogowanego użytkownika.

<?php
@atomjoy
atomjoy / Laravel-Payment-Gateways.md
Last active August 28, 2025 19:01
How to set up a payment system in Laravel that supports multiple payment gateways with interfaces and collection.

Laravel Payment Gateways

How to set up a payment system in Laravel that supports multiple payment gateways with interfaces and collection.

Payment Gateway Interface

<?php

namespace App\Payments\Contracts;
@atomjoy
atomjoy / Laravel-Sanctum-Multi-Guards.md
Last active September 3, 2025 18:05
Laravel sanctum multiple guards.

Laravel Sanctum Multi Guards

Sanctum loguje zawsze guardy z ustawień 'guard' => ['web', 'admin'] trzeba sprawdzać który user jest zalogowany (sanctum guard nie działają podwójne logowania, zawsze brany jest pierwszy guard) można to zmienić dodając auth:web,sanctum i auth:admin,sanctum middleware.

<?php

// Działa to z tokenem i guardami, nawet z podwójnie zalogowanymi userami SPA z testów!

// Użyj web guard a jak nie to sanctum guard
@atomjoy
atomjoy / Laravel-Schedule.md
Created September 5, 2025 08:20
Schedule Laravel.

Schedule Laravel

Polecenia

# Lista
php artisan schedule:list
# Lokalnie
php artisan schedule:work
# Cron
@atomjoy
atomjoy / Laravel-Notification-Email-Test.md
Last active September 8, 2025 11:12
Laravel notification email message testing.

Test Email Notifications in Laravel

How to test email message from notifications in Laravel (MailMessage).

Activation Notification

<?php

namespace App\Notifications;
@atomjoy
atomjoy / Zaokrąglanie-Vat.md
Last active October 4, 2025 08:46
Zaokrąglanie podatku Vat do 1 grosza.

Zaokrąglanie Vat

Kwoty wykazane w fakturze zaokrągla się zawsze do pełnych groszy. Końcówki poniżej 0,5 grosza pomija się, natomiast końcówki od 0,5 grosza i więcej zaokrągla się do 1 grosza.

// Tak ma być
$tax = 17.23;
$tax = 17.23499;
$tax = 17.734956; // Powinno być 17.73 zostawiamy 17.734 i zaokrąglamy czyli 17.73
echo number_format($tax, 2) . "</br>";
@atomjoy
atomjoy / OBS-Browser-Custom-Animations.md
Last active October 9, 2025 11:58
OBS Customizable html animations from a browser source.

OBS Browser Custom Html Animations

OBS Customizable animations from a browser source (!!! jedźiemy !!!).

How to use

Download to pulpit, unzip file, run html file with 2 clicks then copy url from browser to OBS Browser source and set resolution to 1920x 1080px.

@atomjoy
atomjoy / Stripe-Signature-Php.md
Last active October 19, 2025 08:10
Creating a Stripe notification header signature in PHP.

Stripe Header Signature

How to create a Stripe notification header signature in PHP and test it in Laravel.

Create Signature

Stripe signature: 't=timestamp,v1=signature,v0=none',

<?php
@atomjoy
atomjoy / Vue-Store-Computed.md
Last active October 20, 2025 08:58
Store with computed and v-model.

Vue Store Computed

Pinia store

File /stores/targets.js

import { ref, computed, nextTick } from 'vue';
import { defineStore, storeToRefs } from 'pinia';
import { useRoute } from 'vue-router';