Skip to content

Instantly share code, notes, and snippets.

View sebastiaanluca's full-sized avatar
👋

Sebastiaan Luca sebastiaanluca

👋
View GitHub Profile
@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
@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
<?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>
@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]);
<?php
declare(strict_types=1);
namespace Passport\Models;
use Closure;
use Laravel\Passport\Client as PassportClient;
use Ramsey\Uuid\Uuid;
<?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;
alias git-last-release='git describe --tags $(git rev-list --tags="[0-9]*.[0-9]*.[0-9]*" --max-count=1)'
confirm() {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
provider: virtualbox
memory: 8192
cpus: 4
name: project
hostname: local1.project.com.test
ip: 192.168.116.20
authorize: ~/.ssh/id_rsa.pub
keys: