/** * Generates a random string and then checks the database to see if it is unique. * * @param $number * @return string */ public static function generateUniqueSlug($number) { do { $slug = str_random($number); } while (!Photo::isSlugUnique($slug)); //While slug is not unique return $slug; }