Skip to content

Instantly share code, notes, and snippets.

View simonhamp's full-sized avatar
💭
Accidentally learning Rust

Simon Hamp simonhamp

💭
Accidentally learning Rust
View GitHub Profile
@simonhamp
simonhamp / BaseModel.php
Last active March 25, 2020 16:57
Eloquent: Simple Model Event Handling
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
{
/**
* Override the default boot method to register some extra stuff for every child model.
@simonhamp
simonhamp / VersionMatcher.php
Created January 18, 2018 12:16
A simple SemVer parser/matcher
<?php
class VersionMatcher
{
protected $specificity = 'major';
protected $originals = [];
protected $current;
protected $target;
protected static $padDigits;
@simonhamp
simonhamp / AppServiceProvider.php
Last active February 6, 2023 03:19
Laravel: Str::csvToArray macro
<?php
namespace App\Providers;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@davidpiesse
davidpiesse / Schedulable.php
Last active September 7, 2023 15:22
Laravel Custom Class/Model Scheduling
<?php
//Don't forget to change the namespace!
namespace App\Traits;
use Cron\CronExpression;
use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ManagesFrequencies;
trait Schedulable{
@bcnzer
bcnzer / postman-pre-request.js
Last active April 30, 2024 21:20
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',