public function scopeInDirectory($query, $path) { // Make sure the path ends with a directory separator. $path = rtrim(trim($path), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; return $query->where('path', 'LIKE', "{$path}%"); }