Skip to content

Instantly share code, notes, and snippets.

View tristanbailey's full-sized avatar
🏭
Talking to manufacturers

Tristan Bailey tristanbailey

🏭
Talking to manufacturers
View GitHub Profile
#installation
sudo apt-get update
sudo apt-get install -y apache2 libapache2-mod-php5 unzip mysql-server libapache2-mod-auth-mysql php5-mysql php5-intl mcrypt php5-mcrypt
sudo a2enmod php5
sudo php5enmod mcrypt
sudo apt-get install php5-imap
sudo php5enmod imap
cd /tmp/

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

@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(){
@dillinghamio
dillinghamio / currentTeamMembersByRole.md
Last active August 13, 2019 13:55
currentTeamMembersByRole

User's Fellow Members in Laravel Spark

add to your user model

public function teamMembers($role='member')
{
    return $this->currentTeam
 ->users()
@chockenberry
chockenberry / finder_icons.sh
Last active February 10, 2024 19:05
A simple shell script to turn the Finders desktop icons on and off
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write com.apple.finder CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
@dillinghamio
dillinghamio / Laravel Spark Per Team User Subscription.md
Last active April 22, 2022 14:57
Per Team User Subscription in Laravel Spark

Per Team User Subscription in Laravel Spark

If you want the ability to charge a team owner based on how many members their team has, like $10/user/month, then you utilize the Laravel Cashier functionality of incrementing the quantity.

You listen for when a new team member is added and you increase the quantity of the subscription by the amount of users and also listen for when a team member is removed to downsize charges. - Not Braintree Compatible


Within EventServiceProvider.php
'Laravel\Spark\Events\Teams\TeamMemberAdded' => [
@woganmay
woganmay / sample.php
Last active February 24, 2016 09:43
Everything in linfo v3.0.0
<?php
// http://wogan.me/2016/02/21/get-system-information-in-laravel-5-1/
$linfo = new \Linfo\Linfo;
$parser = $linfo->getParser();
$everything = [
'os' => $parser->getOS(),
'cpu' => $parser->getCPU(),
@fevangelou
fevangelou / my.cnf
Last active January 27, 2025 11:12
Optimized my.cnf configuration for MySQL/MariaDB (on cPanel/WHM servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on cPanel/WHM servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated September 2024 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@vielhuber
vielhuber / index.php
Last active June 10, 2023 22:40
PHP-cli: Show progress on command line through echo #php
<?php
for ($i = 100; $i >= 0; $i--) {
/* every output should not be smaller than the previous one, so otherwise you get output formatting errors */
echo str_pad($i, 4, '0', STR_PAD_LEFT)."\r";
usleep(1000);
}
echo PHP_EOL; /* important on the end */
for ($i = 0; $i <= 100; $i++) {
echo "Loading... {$i}%\r";
@vinicius73
vinicius73 / pagination.vue
Created November 5, 2015 14:45
VueJS Pagination directive
<template>
<ul class="pagination">
<li v-show="current_page != 1">
<a href="javascript:;"
aria-label="Previous"
v-on:click="previousPage()">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li v-for="page in total_pages"