Skip to content

Instantly share code, notes, and snippets.

View nateritter's full-sized avatar
🎯
Focusing

Nate Ritter nateritter

🎯
Focusing
View GitHub Profile
@adamwathan
adamwathan / belongs-to-many.sublime-snippet
Last active October 19, 2020 16:59
Eloquent Relationship snippets for Sublime Text
<snippet>
<content><![CDATA[
public function ${1:relationship}()
{
return \$this->belongsToMany(${1/^(.+)$/(?1\u$1:)/g}::class, {$2:table});
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>belt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@dillinghamio
dillinghamio / SparkRoleMiddleware.md
Last active April 8, 2022 03:50
Team Role Middleware For Laravel Spark

Team Role Middleware For Laravel Spark

Makes it simple to use Spark's role feature on routes

Route::group(['middleware'=>'role:owner'], function(){
    // owners only
});

Route::group(['middleware'=>'role:member'], function(){

UsedByTeams Model Trait For Laravel Spark

Automatically limit your models to the current team

So you're using spark, and you have teams enabled. You start creating models and want to have them be team specific. Instead of writing, Model::where('team_id', auth()->user()->currentTeam->id)->get(); use this trait to add that behind the scenes so that every time you call on your model, it's assumed that you mean for the current team.

This assumes that the model has a team_id, while it adds a scope of where team_id = currentTeam->id.

Note: Implicit Route Model Binding in 5.2, auth session doesn't exist at the point of this trait causing issue. fixed in 5.3

@paulund
paulund / phpcs.xml
Created August 20, 2017 16:50
PHP PSR-2 CodeSniffer Config for Laravel
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
-->
@thijskok
thijskok / config.yml
Last active April 4, 2023 05:47
CircleCI 2.0 Laravel build configuration with PHP 7.1, NodeJS, and MySQL support. Runs both PHPunit as well as Laravel Dusk. Proper GD configuration for image editing purposes. Several linters included (requires including them in composer / package.json).
version: 2
jobs:
build:
working_directory: ~/user/repo
environment:
BASH_ENV: ~/.bashrc
docker:
@alexmac05
alexmac05 / gist:efef7a557fcc7ccc89bd17b5ac3cb1a9
Created April 19, 2018 14:57
HelloSign - Overriding the app white labelling settings when doing the embedded iframe loading in JavaScript
HelloSign.init("<?php echo $client_id ?>");
HelloSign.open({
url: "<?php echo $sign_url ?>",
allowCancel: true,
skipDomainVerification: true,
@TfTHacker
TfTHacker / FastStart-StartupScript.js
Last active April 1, 2024 06:39
FastStart Script for Obsidian - makes it easy to delay the startup of plugins
<%*
fastStart = async (filename, delayInSecond) => {
if (tp.file.exists(filename)) {
const f = tp.file.find_tfile(filename);
let plugins = (await app.vault.read(f)).split(/\r?\n/);
setTimeout(async () => {
plugins.forEach(async (p) => await app.plugins.enablePlugin(p))
}, delayInSecond * 1000)
}
}