Skip to content

Instantly share code, notes, and snippets.

View sebastiaanluca's full-sized avatar
👋

Sebastiaan Luca sebastiaanluca

👋
View GitHub Profile
@sebastiaanluca
sebastiaanluca / NewMessage.php
Last active April 11, 2024 12:36
Laravel + Redis + NodeJS + Socket.io pub/sub secure server and client supporting multiple rooms, channels, users, … Add `client.js` to your client app, run `node server.js`, and trigger the Laravel event any way you want to broadcast the data.
<?php
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class NewMessage extends Event implements ShouldBroadcast
{
@sebastiaanluca
sebastiaanluca / CarbonImmutableCaster.php
Last active March 24, 2024 14:39
Lazy Laravel Harvest API service
<?php
declare(strict_types=1);
namespace App\DataTransferObjects;
use Carbon\CarbonImmutable;
use Spatie\DataTransferObject\Caster;
class CarbonImmutableCaster implements Caster
@sebastiaanluca
sebastiaanluca / after_activate_new_release.sh
Created June 1, 2018 11:50
Example of how to gracefully deploy a new release when using Envoyer. Optionally, you could just stop/resume only the Horizon daemons, but since we only have one Supervisor daemon, this works fine.
# After *Activate New Release*
cd {{ release }}
php artisan cache:clear
php artisan view:clear
php artisan purifier:clear
php artisan config:cache
php artisan route:cache
@sebastiaanluca
sebastiaanluca / Controller.php
Last active March 7, 2023 23:51
A HasMany relation sync method implementation using macros
<?php
$business->locations()->sync([1, 42, 16, 8]);
@sebastiaanluca
sebastiaanluca / CombinedNotification.php
Created October 2, 2017 02:07
Queued jobs in different locales. See https://github.com/laravel/internals/issues/394 for more info.
<?php
namespace App\Notifications;
use App\Helpers\RemembersLocale;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Notifications\Channels\FirebaseChannel;
<?php
declare(strict_types=1);
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
@sebastiaanluca
sebastiaanluca / 2021_01_01_000003_ensure_owner_user_exists.php
Created August 24, 2022 13:57
Simple Laravel database state system to ensure database content is up-to-date (in addition to its schema using migrations).
<?php
declare(strict_types=1);
use App\Domain\Users\User;
use App\State;
use Illuminate\Support\Facades\Hash;
return new class extends State {
public function up(): void
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>#AddProperties</key>
<array>
<dict>
<key>Device</key>
<string>NVidia</string>
<key>Disabled</key>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ACPI</key>
<dict>
<key>DSDT</key>
<dict>
<key>Fixes</key>
<dict>