public static function findExistingReferences($model, $field)
    {
        $invalid      = true;
        $uniqueString = null;

        while ($invalid == true) {
            // Create a new random string.
            $uniqueString = Str::random($model::$uniqueStringLimit);

            // Look for any instances of that string on the model.
            $existingReferences = $model::where($field, $uniqueString)->count();

            // If none exist, this is a valid unique string.
            if ($existingReferences == 0) {
                $invalid = false;
            }
        }

        return $uniqueString;
    }
public static function findExistingReferences($model, $field)
    {
        $invalid      = true;
        $uniqueString = null;

        while ($invalid == true) {
            // Create a new random string.
            $uniqueString = Str::random($model::$uniqueStringLimit);

            // Look for any instances of that string on the model.
            $existingReferences = $model::where($field, $uniqueString)->count();

            // If none exist, this is a valid unique string.
            if ($existingReferences == 0) {
                $invalid = false;
            }
        }

        return $uniqueString;
    }
public static function findExistingReferences ( $ model , $ field ) { $ invalid = true ; $ uniqueString = null ; while ( $ invalid == true ) { // Create a new random string. $ uniqueString = Str :: random ( $ model :: $ uniqueStringLimit ) ; // Look for any instances of that string on the model. $ existingReferences = $ model :: where ( $ field , $ uniqueString ) -> count ( ) ; // If none exist, this is a valid unique string. if ( $ existingReferences == 0 ) { $ invalid = false ; } } return $ uniqueString ; }
Make sure the uniqueId is always unique.

@param string $model The model to search on.
@param        $field The field to search on.

@return string
Make sure the uniqueId is always unique .