Skip to content

Instantly share code, notes, and snippets.

View devhammed's full-sized avatar
💭
Changing the world, one dollar sign in my PHP code at a time!

Hammed Oyedele devhammed

💭
Changing the world, one dollar sign in my PHP code at a time!
View GitHub Profile
@devhammed
devhammed / nigeria-state-and-lgas.json
Last active November 17, 2024 14:24
Nigeria States and LGAs in one JSON file
[
{
"state": "Adamawa",
"alias": "adamawa",
"lgas": [
"Demsa",
"Fufure",
"Ganye",
"Gayuk",
"Gombi",
@devhammed
devhammed / countries.json
Last active November 12, 2024 20:44
Countries with Name, Dial Code, Emoji Flag and ISO Code
[
{
"name": "Afghanistan",
"flag": "🇦🇫",
"code": "AF",
"dial_code": "+93"
},
{
"name": "Åland Islands",
"flag": "🇦🇽",
@devhammed
devhammed / Country.php
Last active December 10, 2023 17:23
World Countries as a Sushi model that can be used as a regular Laravel model (https://github.com/calebporzio/sushi) and I also provided a Laravel config file if you prefer the configuration method but it can also be adapted for other PHP projects!
<?php
namespace App\Models;
use Sushi\Sushi;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
use Sushi;
@devhammed
devhammed / SpatieLaravelDataSynthesizer.php
Last active February 6, 2024 11:51
This is a Livewire 3 Synthesizer (https://livewire.laravel.com/docs/synthesizers) for classes using spatie/laravel-data package (https://spatie.be/docs/laravel-data/v3/introduction)!
<?php
namespace App\Support\Synthesizers;
use Spatie\LaravelData\Data;
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
class SpatieLaravelDataSynthesizer extends Synth
{
public static string $key = 'spld';
@devhammed
devhammed / .gitlab-ci.yml
Last active February 1, 2024 17:35
GitLab Deploys Pipeline for Laravel (with environments and rollback support)
stages:
- deploy
production-deploy:
stage: deploy
environment: production
only:
- /^v.*$/
script:
- which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
@devhammed
devhammed / MoneyInput.php
Last active October 25, 2024 11:44
Filament Money Input Component (this assumes that you are using the MoneyCast from https://github.com/akaunting/laravel-money package for the field in your model, this package is depended on by default in FilamentPHP so this should work out of the box))
<?php
namespace App\Frontend\Forms\Components;
use Closure;
use Akaunting\Money\Money;
use Filament\Support\RawJs;
use Akaunting\Money\Currency;
use Filament\Forms\Components\TextInput;
@devhammed
devhammed / PinInput.php
Created October 25, 2024 13:09
Filament PIN Input
<?php
namespace App\Frontend\Forms\Components;
use Closure;
use Filament\Forms\Components\Field;
class PinInput extends Field
{
protected Closure|int|null $length = null;
@devhammed
devhammed / LaravelHelpers.php
Created October 25, 2024 13:14
My favourite Laravel helper functions
<?php
if ( ! function_exists('vite')) {
/**
* Get the Vite instance or Vite asset URL for the given file.
*/
function vite(?string $file = null, ?string $buildDirectory = null): Illuminate\Foundation\Vite|string
{
$vite = app(Illuminate\Foundation\Vite::class);
@devhammed
devhammed / laravel-github-actions-deploy.yml
Created October 26, 2024 08:10
Laravel GitHub Actions Deployment Workflow (Filament, Scheduler, Queue, Reverb, Pulse, NPM)
name: Deploy to Servers
on:
push:
branches:
- production
jobs:
production-deploy:
runs-on: ubuntu-latest
@devhammed
devhammed / CurrencySynthesizer.php
Created October 26, 2024 08:58
Livewire Synthesizer for Money and Currency objects from https://github.com/akaunting/laravel-money package.
<?php
namespace App\Support\Synthesizers;
use Akaunting\Money\Currency;
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
class CurrencySynthesizer extends Synth
{
public static string $key = 'currency';