Skip to content

Instantly share code, notes, and snippets.

View sebastiaanluca's full-sized avatar
👋

Sebastiaan Luca sebastiaanluca

👋
View GitHub Profile
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use Illuminate\Database\Eloquent\Relations\Relation;
<?php
declare(strict_types=1);
namespace Passport\Models;
use Closure;
use Laravel\Passport\Client as PassportClient;
use Ramsey\Uuid\Uuid;
@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]);
<?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>
<?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>
@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 / 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