This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getCreatedAtAttribute($value){ | |
return \Carbon\Carbon::createFromTimestampUTC(strtotime($value))->timezone(User::currentUser()->timezone); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = User::first($id) | |
//Generate Token | |
do { | |
$token = str_random(128); | |
} while (User::where('token', $token)->exists()); | |
$user->token = $token; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Http\Middleware; | |
use App\Affiliate; | |
use App\Referral; | |
use Closure; | |
use Cookie; | |
class TrackAffiliates | |
{ | |
/** | |
* Run the request filter. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Your Stripe Plan Model | |
protected static function boot() { | |
parent::boot(); | |
static::creating(function($model) { // before create() method call this | |
$model->stripe_id = str_slug($model->name); | |
Stripe\Stripe::setApiKey(env('STRIPE_SECRET')); | |
try{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function scopeActivePlansForUser($query, $user){ | |
$plansArray = $user->subscriptions()->get()->sortBy('ends_at')->pluck('stripe_plan')->toArray(); | |
$ordered = "'".implode("','",$plansArray)."'"; // format order: '1','3', | |
return $query->whereIn('stripe_id',$plansArray)->orderByRaw(\DB::raw("FIELD(stripe_id, $ordered)")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Logs; | |
use Monolog\Formatter\LineFormatter; | |
use Monolog\Handler\FirePHPHandler; | |
use Monolog\Logger as Log; | |
use Monolog\Handler\StreamHandler; | |
//Example: | |
//Logger::write('info','Auth', 'User Logged In', $request->user()->getLoggerAttributes()); | |
class Logger { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Source: https://addyosmani.com/blog/essential-js-namespacing/ | |
var myApp = myApp || {}; | |
myApp.utils = {}; | |
(function() { | |
var val = 5; | |
this.getValue = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Tutorial: https://medium.com/@danielalvidrez/adding-es6-promises-to-animate-css-869156ec0cbd **/ | |
$(document).ready(function(){ | |
/** Add Support for Animate.css ES6 Promises **/ | |
$.fn.extend({ | |
animateCss: function (animationName, duration = 1.0, delay = 0) { | |
let _root = $(this); | |
return new Promise((resolve, reject) => { | |
//Animation Event Definitions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$.fn.select2.defaults.set("theme","bootstrap"); | |
function DDsetState($element, $state){ | |
$element.select2('val', null); | |
if($state === true){ | |
$element.prop("disabled", false); | |
}else{ | |
$element.prop("disabled", true); |
OlderNewer