Last active
September 25, 2017 04:41
-
-
Save bayareawebpro/35f02b4dc93ab0743207a375bd0b51e0 to your computer and use it in GitHub Desktop.
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)")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment