Skip to content

Instantly share code, notes, and snippets.

View sawirricardo's full-sized avatar
👋

Ricardo Sawir sawirricardo

👋
View GitHub Profile
@MrPunyapal
MrPunyapal / BelongsToTeam.php
Last active March 20, 2025 07:02
Enhance Laravel Access Control with 'BelongsToTeam' Trait: Simplify Team-Based Permissions
<?php
namespace App\Traits\Models;
use App\Models\Team;
use Illuminate\Database\Eloquent\Builder;
trait BelongsToTeam
{
// This method is executed when a new model is being created.
@aniket-magadum
aniket-magadum / 2023_11_01_025054_create_http_logs_table.php
Last active December 16, 2023 21:22
Laravel Logging Http Client Request and Response
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
@nathandaly
nathandaly / BaseResource.php
Last active August 12, 2025 21:28
Tenancy for Laravel & Filament V3 (Tenant per database)
<?php
/**
* Below is an the extended Filament resource your tenant panel resources
* will have to extend so that the queries are scoped properly.
*/
namespace App\Filament;
use Filament\Resources\Resource;
@awcodes
awcodes / NowAction.php
Created August 18, 2023 21:19
NowAction
<?php
namespace ...
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Set;
class NowAction extends Action
{
<?php
namespace App\Console\Commands\Concerns;
use React\EventLoop\Loop;
trait RunsLoop
{
protected function loop(callable $callback, float $interval, float $lifetime): void
{
{
"indentSize": 4,
"wrapAttributes": "auto",
"wrapLineLength": 200,
"endWithNewLine": true,
"endOfLine": "LF",
"useTabs": false,
"sortTailwindcssClasses": true,
"sortHtmlAttributes": "none",
"noMultipleEmptyLines": true,
@ciiqr
ciiqr / zod-optional-null.ts
Last active February 17, 2026 14:36
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@RohmanBenyRiyanto
RohmanBenyRiyanto / Flutter Custom Tickets using Clip Path.dart
Last active February 24, 2025 08:47
Create a custom ticket card display in flutter
class CustomTicket extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final path = Path();
//Radius
path.addRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(0, 0, size.width, size.height),
const Radius.circular(8),
),