-
-
Save muskie9/2542df4d062f764f64ba to your computer and use it in GitHub Desktop.
Assumes at least 4 Testimonials are <= 750 characters. Doesn't get 2 random, sort is always the same.
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
public function getTestimonials(){ | |
return Testimonial::get() | |
->filterByCallback( | |
function($item, $list) { | |
return strlen($item->Description) <= 750; | |
} | |
) | |
->sort('RAND()') | |
->limit(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved:
->sort('RAND()')
needs to come before->filterByCallback()