Skip to content

Instantly share code, notes, and snippets.

View newtonjob's full-sized avatar
🧑‍🍳
Cooking

Newton Job newtonjob

🧑‍🍳
Cooking
View GitHub Profile
@newtonjob
newtonjob / form.js
Created February 2, 2026 08:12
Form plugin for Alpine.js
document.addEventListener('alpine:init', () => {
Alpine.magic('form', el => () => {
return Alpine.reactive({
processing: false,
recentlySuccessful: false,
errors: {},
submit() {
return axios.post(el.action, el).then(response => {
this.errors = {};
this.recentlySuccessful = true;
<?php
namespace App\Models\Concerns;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
<?php
namespace App\Models\Concerns;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Uri;
trait HasPhoto
@newtonjob
newtonjob / MagicLoginLink.php
Created March 21, 2025 14:38
Magic login link using Laravel's `Password` broker