Skip to content

Instantly share code, notes, and snippets.

@JoshuaDoshua
JoshuaDoshua / App\Enums\Day.php
Last active November 4, 2022 04:37
Weekday FlaggedEnum for BemSampo/Laravel-Enum
<?php
namespace App\Enums;
use BenSampo\Enum\FlaggedEnum;
final class Day extends FlaggedEnum
{
const Monday = 1 << 0;
const Tuesday = 1 << 1;
@JoshuaDoshua
JoshuaDoshua / arrayPull.php
Created October 12, 2021 15:33
PHP Helpers
<?php
/**
* Pull and remove an element from an array
*
* @param array $array
* @param mixed $key
* @param mixed $default
* @return mixed
*/
if (!function_exists('arrayPull')):
@JoshuaDoshua
JoshuaDoshua / TestCase.php
Created April 5, 2021 04:53
assertDatabaseHasModel Laravel Unit Assertion
<?php
...
/**
* Format date values for asserting database model existence
*
* @param string $table
* @param Model $model
* @param ?string $connection
* @return bool
### Keybase proof
I hereby claim:
* I am joshuadoshua on github.
* I am joshuadoshua (https://keybase.io/joshuadoshua) on keybase.
* I have a public key ASC4_LHMJ3yfvo81T-Qb2qVXgkJXz-L1_zedluZjva_nYAo
To claim this, I am signing this object:
@JoshuaDoshua
JoshuaDoshua / paydays.ics
Created March 30, 2021 18:37
.ics for paydays on the 15th & last of month, or Friday before
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART;VALUE=DATE:20210315
DTEND;VALUE=DATE:20210316
RRULE:FREQ=MONTHLY;BYMONTHDAY=13,14,15;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
LOCATION:
SEQUENCE:0
<?php
namespace App\Concerns;
use App\Models\Tag;
use App\Models\Taggable as TaggableMorph;
trait Taggable
{
/**
@JoshuaDoshua
JoshuaDoshua / PasswordRequirementsRule.php
Created June 16, 2019 23:12
Laravel: Password Requirements Rule
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class PasswordRequirementsRule implements Rule
{
// @var string
//private $regex;
@JoshuaDoshua
JoshuaDoshua / MakeEntityCommand.php
Last active December 4, 2019 18:23
laravel shortcut artisan command to quickly do all entity generation commands
<?php
namespace App\Console\Commands;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
class MakeEntityCommand extends Command
{
/**
@JoshuaDoshua
JoshuaDoshua / addtogcal.php
Last active August 3, 2018 13:32 — forked from petertwise/addtogcal.php
Function to create Add to Google Calendar link
<?php
function squarecandy_add_to_gcal(
$name,
$startDate,
$endDate = false,
$isAllDay = false,
$description = null,
$location = null
) {
/**
* get previous/next post
* default WP postnav is limited
* modified from link below to handle post_type and cats differently
*
* @param string $direction [which direction to go]
* @param string $postTypes [what post types should w]
* @return [type] [description]
*/
function my_adjacent_post($direction = 'prev', $inSameTax = false, $tax = null, $postTypes = null, $reverseTax = false)