Skip to content

Instantly share code, notes, and snippets.


Dan Alvidrez bayareawebpro

Block or report user

Report or block bayareawebpro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View laravel-timezone-ancestor.php
public function getCreatedAtAttribute($value){
return \Carbon\Carbon::createFromTimestampUTC(strtotime($value))->timezone(User::currentUser()->timezone);
View uniqueToken.php
$user = User::first($id)
//Generate Token
do {
$token = str_random(128);
} while (User::where('token', $token)->exists());
$user->token = $token;
bayareawebpro / TrackAffiliates.php
Last active Sep 16, 2017
Affiliate Tracker Middleware
View TrackAffiliates.php
<?php namespace App\Http\Middleware;
use App\Affiliate;
use App\Referral;
use Closure;
use Cookie;
class TrackAffiliates
* Run the request filter.
bayareawebpro / StripePlanEvents.php
Last active Sep 16, 2017
Sync Stripe Plan with Local Model
View StripePlanEvents.php
//Your Stripe Plan Model
protected static function boot() {
static::creating(function($model) { // before create() method call this
$model->stripe_id = str_slug($model->name);
View SocialiteLoginRedirect.php
Route::get('social/{provider}', 'Auth\SocialController@redirect');
Route::get('social/{provider}/callback', 'Auth\SocialController@handle');
class SocialController extends Controller{
public function redirect(Request $request, $provider){
return Socialite::driver($provider)->fields([
View StripePlanModel.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)"));
View Logger.php
<?php namespace App\Logs;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\FirePHPHandler;
use Monolog\Logger as Log;
use Monolog\Handler\StreamHandler;
//Logger::write('info','Auth', 'User Logged In', $request->user()->getLoggerAttributes());
class Logger {
View JavascriptNamespacingPatterns.js
var myApp = myApp || {};
myApp.utils = {};
(function() {
var val = 5;
this.getValue = function() {
View AnimateCssPromise.js
/** Tutorial: **/
/** Add Support for Animate.css ES6 Promises **/
animateCss: function (animationName, duration = 1.0, delay = 0) {
let _root = $(this);
return new Promise((resolve, reject) => {
//Animation Event Definitions
View Select2MultiDropDown.js
$(document).ready(function() {
function DDsetState($element, $state){
$element.select2('val', null);
if($state === true){
$element.prop("disabled", false);
$element.prop("disabled", true);
You can’t perform that action at this time.